Skip to content

{Compute} az vm: Migrate commands to CodeGen based#31658

Merged
zhoxing-ms merged 9 commits intoAzure:devfrom
yanzhudd:migrate-vm-commands
Jun 17, 2025
Merged

{Compute} az vm: Migrate commands to CodeGen based#31658
zhoxing-ms merged 9 commits intoAzure:devfrom
yanzhudd:migrate-vm-commands

Conversation

@yanzhudd
Copy link
Copy Markdown
Contributor

@yanzhudd yanzhudd commented Jun 16, 2025

Related command

az vm capture/delete/get-instance-view/list

Description

Migrate commands to CodeGen based
aaz PR: Azure/aaz#783

Testing Guide

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


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

@yanzhudd yanzhudd self-assigned this Jun 16, 2025
Copilot AI review requested due to automatic review settings June 16, 2025 03:33
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jun 16, 2025

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

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

azure-client-tools-bot-prd bot commented Jun 16, 2025

⚠️AzureCLI-BreakingChangeTest
⚠️vm
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd vm capture cmd vm capture added parameter no_wait
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter overwrite: added property aaz_default=True
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter overwrite: added property aaz_type=bool
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter overwrite: added property choices=['0', '1', 'f', 'false', 'n', 'no', 't', 'true', 'y', 'yes']
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter overwrite: added property nargs=?
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter overwrite: added property type=bool
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter resource_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter resource_group_name: added property type=string
⚠️ 1010 - ParaPropUpdate vm capture cmd vm capture update parameter resource_group_name: updated property name from resource_group_name to resource_group
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter storage_container: added property aaz_default=vhds
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter storage_container: added property aaz_type=string
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter storage_container: added property type=string
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter vhd_name_prefix: added property aaz_type=string
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter vhd_name_prefix: added property type=string
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter vm_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd vm capture cmd vm capture update parameter vm_name: added property type=string
⚠️ 1010 - ParaPropUpdate vm capture cmd vm capture update parameter vm_name: updated property name from vm_name to name
⚠️ 1004 - CmdPropRemove vm delete cmd vm delete removed property confirmation
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter force_deletion: added property aaz_type=bool
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter force_deletion: added property choices=['0', '1', 'f', 'false', 'n', 'no', 't', 'true', 'y', 'yes']
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter force_deletion: added property nargs=?
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter force_deletion: added property type=bool
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter no_wait: added property aaz_type=bool
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter no_wait: added property choices=['0', '1', 'f', 'false', 'n', 'no', 't', 'true', 'y', 'yes']
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter no_wait: added property nargs=?
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter no_wait: added property type=bool
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter resource_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter resource_group_name: added property type=string
⚠️ 1010 - ParaPropUpdate vm delete cmd vm delete update parameter resource_group_name: updated property name from resource_group_name to resource_group
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter vm_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd vm delete cmd vm delete update parameter vm_name: added property type=string
⚠️ 1010 - ParaPropUpdate vm delete cmd vm delete update parameter vm_name: updated property name from vm_name to name

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Jun 16, 2025

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

@github-actions
Copy link
Copy Markdown

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
Copy Markdown
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 several Azure VM commands to a CodeGen-based implementation using the AAZ framework, replacing manual SDK calls with generated command classes and updating schema types.

  • Introduces a new VMCapture class in operations/vm.py to handle vm capture output and registers it in the command table.
  • Refactors create_vm, get_instance_view, get_vm_details, and list_vm in custom.py to use dictionary-style access and AAZ command invocations.
  • Updates AAZ schemas in _update.py and _show.py to replace AAZFreeFormDictType with AAZDictType and define element types, and adds generated code for delete and capture in the AAZ folder.

Reviewed Changes

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

File Description
src/azure-cli/azure/cli/command_modules/vm/operations/vm.py Added VMCapture class and import for CodeGen-based capture.
src/azure-cli/azure/cli/command_modules/vm/custom.py Refactored identity handling, get_instance_view, and listing.
src/azure-cli/azure/cli/command_modules/vm/commands.py Registered vm capture command via command_table.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/* Updated schemas (_update.py, _show.py), added _delete.py, _capture.py, and adjusted __init__.py.
Comments suppressed due to low confidence (1)

src/azure-cli/azure/cli/command_modules/vm/custom.py:1376

  • [nitpick] The variable name filter shadows the built-in filter() function. Consider renaming it to filter_expr or filter_str to avoid confusion.
filter = "'virtualMachineScaleSet/id' eq '{}'".format(vmss)

Comment thread src/azure-cli/azure/cli/command_modules/vm/operations/vm.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/vm/custom.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/vm/commands.py
@zhoxing-ms zhoxing-ms merged commit f6cb820 into Azure:dev Jun 17, 2025
49 checks passed
@yanzhudd yanzhudd deleted the migrate-vm-commands branch June 17, 2025 07:53
@cceneag
Copy link
Copy Markdown

cceneag commented Jun 17, 2025

👍

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