Skip to content

{Compute} az vm list-usage & az vm stop: Migrate commands to aaz-based implementation#32925

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

{Compute} az vm list-usage & az vm stop: Migrate commands to aaz-based implementation#32925
william051200 wants to merge 9 commits intoAzure:devfrom
william051200:vm-migration

Conversation

@william051200
Copy link
Member

Related command

az vm list-usage
az vm stop

Description

Migration from mgmt.compute to aaz-based

aaz Azure/aaz#957

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 March 6, 2026 01:47
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Mar 6, 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 Mar 6, 2026

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

@yonzhan
Copy link
Collaborator

yonzhan commented Mar 6, 2026

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

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

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

This PR migrates the az vm list-usage and az vm stop commands from SDK-based implementations (using azure.mgmt.compute) to AAZ-based implementations (auto-generated code from aaz-dev-tools). It also consolidates the vm command group in commands.py by merging the compute_vm_sdk command group into a bare vm group and removing associated min_api constraints.

Changes:

  • Adds new AAZ auto-generated files for vm stop (_stop.py) and vm list-usage (_list_usage.py) targeting API version 2024-11-01.
  • Creates a VMListUsage wrapper class in operations/vm.py that customizes the output to convert currentValue and limit to strings and surfaces localizedValue.
  • Reorganizes commands.py to consolidate VM commands into a single command group, removing the compute_vm_sdk group and min_api constraints for migrated commands.

Reviewed changes

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

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/_stop.py New AAZ auto-generated implementation for vm stop
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/_list_usage.py New AAZ auto-generated implementation for vm list-usage
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/__init__.py Exports new _list_usage and _stop modules
src/azure-cli/azure/cli/command_modules/vm/operations/vm.py Adds VMListUsage wrapper with output transformation
src/azure-cli/azure/cli/command_modules/vm/commands.py Consolidates command group, registers new AAZ-based vm stop and vm list-usage

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

az vm stop --resource-group MyResourceGroup --name MyVm

:example: Power off a running VM without shutting down.
az vm stop --resource-group MyResourceGroup --name MyVm --skip-shutdow
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

Typo in the example: --skip-shutdow is missing the trailing n. It should be --skip-shutdown.

Suggested change
az vm stop --resource-group MyResourceGroup --name MyVm --skip-shutdow
az vm stop --resource-group MyResourceGroup --name MyVm --skip-shutdown

Copilot uses AI. Check for mistakes.
from .operations.vm import VMCapture
from .operations.vm import VMCapture, VMListUsage
self.command_table['vm capture'] = VMCapture(loader=self)
self.command_table['vm list-usage'] = VMListUsage(loader=self)
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The old vm list-usage command had a table_transformer='[].{Name:localName, CurrentValue:currentValue, Limit:limit}' for formatting -o table output. The new registration at line 304 does not include a table_transformer. This means table output will show all raw fields rather than the concise columns users expect. Consider adding a table_transformer to VMListUsage(loader=self), updated to match the new field names (e.g., localizedValue instead of localName).

Suggested change
self.command_table['vm list-usage'] = VMListUsage(loader=self)
self.command_table['vm list-usage'] = VMListUsage(loader=self, table_transformer=transform_vm_usage_list)

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +64
_args_schema.name = AAZStrArg(
options=["-n", "--name"],
help="The name of the virtual machine.",
required=True,
id_part="name",
)
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The name argument is missing configured_default="vm" and the --vm-name option alias, which are present in every other VM command in this directory (e.g., _deallocate.py, _restart.py, _start.py, _reimage.py, etc.). Without configured_default="vm", users who have set a default VM name via az configure --defaults vm=<name> will find that az vm stop no longer picks up the default. The argument should be named vm_name with options=["-n", "--name", "--vm-name"] and include configured_default="vm" to be consistent with the other commands.

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