{Compute} az vm list-usage & az vm stop: Migrate commands to aaz-based implementation#32925
{Compute} az vm list-usage & az vm stop: Migrate commands to aaz-based implementation#32925william051200 wants to merge 9 commits intoAzure:devfrom
az vm list-usage & az vm stop: Migrate commands to aaz-based implementation#32925Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
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). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
There was a problem hiding this comment.
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) andvm list-usage(_list_usage.py) targeting API version 2024-11-01. - Creates a
VMListUsagewrapper class inoperations/vm.pythat customizes the output to convertcurrentValueandlimitto strings and surfaceslocalizedValue. - Reorganizes
commands.pyto consolidate VM commands into a single command group, removing thecompute_vm_sdkgroup andmin_apiconstraints 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 |
There was a problem hiding this comment.
Typo in the example: --skip-shutdow is missing the trailing n. It should be --skip-shutdown.
| az vm stop --resource-group MyResourceGroup --name MyVm --skip-shutdow | |
| az vm stop --resource-group MyResourceGroup --name MyVm --skip-shutdown |
| 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) |
There was a problem hiding this comment.
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).
| self.command_table['vm list-usage'] = VMListUsage(loader=self) | |
| self.command_table['vm list-usage'] = VMListUsage(loader=self, table_transformer=transform_vm_usage_list) |
| _args_schema.name = AAZStrArg( | ||
| options=["-n", "--name"], | ||
| help="The name of the virtual machine.", | ||
| required=True, | ||
| id_part="name", | ||
| ) |
There was a problem hiding this comment.
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.
Related command
az vm list-usageaz vm stopDescription
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.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.