Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 2 additions & 7 deletions src/azure-cli/azure/cli/command_modules/vm/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from azure.cli.command_modules.vm._client_factory import (cf_vm,
cf_vm_ext, cf_vm_ext_image,
cf_vm_image, cf_vm_image_term, cf_usage,
cf_vm_image_term, cf_usage,
cf_vmss, cf_images,
cf_galleries, cf_gallery_images, cf_gallery_image_versions,
cf_proximity_placement_groups,
Expand Down Expand Up @@ -82,11 +82,6 @@ def load_command_table(self, _):
client_factory=cf_vm_ext_image
)

compute_vm_image_sdk = CliCommandType(
operations_tmpl='azure.mgmt.compute.operations#VirtualMachineImagesOperations.{}',
client_factory=cf_vm_image
)

compute_vm_image_term_sdk = CliCommandType(
operations_tmpl='azure.mgmt.marketplaceordering.operations#MarketplaceAgreementsOperations.{}',
client_factory=cf_vm_image_term
Expand Down Expand Up @@ -341,7 +336,7 @@ def load_command_table(self, _):
with self.command_group('vm extension image', compute_vm_extension_image_sdk) as g:
g.custom_command('list', 'list_vm_extension_images')

with self.command_group('vm image', compute_vm_image_sdk) as g:
with self.command_group('vm image') as g:
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compute_vm_image_sdk is no longer used after removing it from with self.command_group('vm image', ...), so it becomes dead code inside load_command_table. Either remove the unused compute_vm_image_sdk CliCommandType definition or reintroduce it if some vm image commands still require the SDK operations template.

Suggested change
with self.command_group('vm image') as g:
with self.command_group('vm image', compute_vm_image_sdk) as g:

Copilot uses AI. Check for mistakes.
g.custom_command('list-offers', 'list_offers')
g.custom_command('list-publishers', 'list_publishers')
g.custom_command('list-skus', 'list_sku')
Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from ._vm_diagnostics_templates import get_default_diag_config

from ._actions import (load_images_from_aliases_doc, load_extension_images_thru_services,
load_images_thru_services, _get_latest_image_version, _get_latest_image_version_by_aaz)
load_images_thru_services, _get_latest_image_version_by_aaz)
from ._client_factory import (_compute_client_factory, cf_vm_image_term)

from .aaz.latest.vm.disk import AttachDetachDataDisk
Expand Down Expand Up @@ -2802,7 +2802,7 @@ def show_vm_image(cmd, urn=None, publisher=None, offer=None, sku=None, version=N
elif len(items) == 4:
publisher, offer, sku, version = urn.split(":")
if version.lower() == 'latest':
version = _get_latest_image_version(cmd.cli_ctx, location, publisher, offer, sku)
version = _get_latest_image_version_by_aaz(cmd.cli_ctx, location, publisher, offer, sku)
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When --urn includes an edge zone (5 segments) and the version is latest, the latest-version resolver is called without passing edge_zone. This will resolve against the non-edge-zone image list and can return an incorrect/nonexistent version for the specified edge zone. Pass edge_zone=edge_zone into _get_latest_image_version_by_aaz in this branch.

Suggested change
version = _get_latest_image_version_by_aaz(cmd.cli_ctx, location, publisher, offer, sku)
version = _get_latest_image_version_by_aaz(cmd.cli_ctx, location, publisher, offer, sku,
edge_zone=edge_zone)

Copilot uses AI. Check for mistakes.
elif not publisher or not offer or not sku or not version:
raise RequiredArgumentMissingError(error_msg)
if edge_zone is not None:
Expand Down