Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[azure] support latest version for image id in azure cloud #4580

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sky/clouds/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ def get_image_size(cls, image_id: str, region: Optional[str]) -> float:
# not the image location. Marketplace image is globally available.
region = 'eastus'
publisher, offer, sku, version = image_id.split(':')
# Since the Azure SDK requires explicitly specifying the image version number,
# when the version is "latest," we need to manually query the current latest version.
if version == 'latest':
versions = compute_client.virtual_machine_images.list(
location=region,
publisher_name=publisher,
offer=offer,
skus=sku)
latest_version = max(versions, key=lambda x: x.name)
version = latest_version.name
try:
image = compute_client.virtual_machine_images.get(
region, publisher, offer, sku, version)
Expand Down
Loading