Skip to content

{Compute} az vm image: Migrate command group to aaz-based implementation#32867

Open
william051200 wants to merge 2 commits intoAzure:devfrom
william051200:vm-image-migration
Open

{Compute} az vm image: Migrate command group to aaz-based implementation#32867
william051200 wants to merge 2 commits intoAzure:devfrom
william051200:vm-image-migration

Conversation

@william051200
Copy link
Member

Related command

az vm image accept-terms
az vm image terms accept
az vm image terms cancel
az vm image terms cancel

Description

Migration from mgmt.compute to aaz-based

Testing Guide

History Notes


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings February 27, 2026 07:18
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Feb 27, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Feb 27, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@william051200 william051200 changed the title {Compute} az vm image: Migrate command group to aaz-based implementation {Compute} az vm image: Migrate command group to aaz-based implementation Feb 27, 2026
@yonzhan
Copy link
Collaborator

yonzhan commented Feb 27, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates parts of the az vm image command group away from the mgmt.compute SDK toward AAZ-based implementations, particularly around resolving and showing VM image versions.

Changes:

  • Switch az vm image show “latest” version resolution to an AAZ-based resolver.
  • Remove the compute_vm_image_sdk operations template from the vm image command group registration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/azure-cli/azure/cli/command_modules/vm/custom.py Uses AAZ to resolve the latest VM image version when --urn ...:latest is provided.
src/azure-cli/azure/cli/command_modules/vm/commands.py Registers vm image commands without the mgmt.compute SDK command type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot Compute az vm/vmss/image/disk/snapshot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants