Skip to content

{Compute} az vm host: Migrate command group to aaz-based implementation#32908

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

{Compute} az vm host: Migrate command group to aaz-based implementation#32908
william051200 wants to merge 7 commits intoAzure:devfrom
william051200:vm-host-migration

Conversation

@william051200
Copy link
Member

Related command

az vm host create
az vm host show
az vm host get-instance-view
az vm host update

Description

Migration from mgmt.compute to aaz-based

aaz Azure/aaz#953

Testing Guide

History Notes


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

@william051200 william051200 requested a review from jsntcy as a code owner March 5, 2026 03:20
Copilot AI review requested due to automatic review settings March 5, 2026 03:20
@azure-client-tools-bot-prd
Copy link

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

⚠️AzureCLI-BreakingChangeTest
⚠️vm
rule cmd_name rule_message suggest_message
⚠️ 1010 - ParaPropUpdate vm host show cmd vm host show update parameter expand: updated property choices from ['instanceView', 'userData'] to ['instanceView', 'resiliencyView', 'userData']
⚠️ 1006 - ParaAdd vm host update cmd vm host update added parameter no_wait
⚠️ 1008 - ParaPropAdd vm host update cmd vm host update update parameter host_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd vm host update cmd vm host update update parameter host_group_name: added property type=string
⚠️ 1008 - ParaPropAdd vm host update cmd vm host update update parameter host_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd vm host update cmd vm host update update parameter host_name: added property type=string
⚠️ 1008 - ParaPropAdd vm host update cmd vm host update update parameter properties_to_add: added property aaz_type=AAZGenericUpdateAddArg
⚠️ 1008 - ParaPropAdd vm host update cmd vm host update update parameter properties_to_remove: added property aaz_type=AAZGenericUpdateRemoveArg
⚠️ 1008 - ParaPropAdd vm host update cmd vm host update update parameter properties_to_set: added property aaz_type=AAZGenericUpdateSetArg
⚠️ 1008 - ParaPropAdd vm host update cmd vm host update update parameter resource_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd vm host update cmd vm host update update parameter resource_group_name: added property type=string
⚠️ 1010 - ParaPropUpdate vm host update cmd vm host update update parameter resource_group_name: updated property name from resource_group_name to resource_group

@github-actions
Copy link

github-actions bot commented Mar 5, 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>

@yonzhan
Copy link
Collaborator

yonzhan commented Mar 5, 2026

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

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 the az vm host command group away from the azure.mgmt.compute SDK to an AAZ-based implementation, aligning dedicated host operations with the newer generated command surface.

Changes:

  • Replaces vm host create and vm host get-instance-view custom implementations to invoke AAZ commands.
  • Replaces vm host update (generic update via SDK) with an AAZ Update command wrapped by a small schema customizer.
  • Removes the dedicated-host SDK client factory wiring from vm/commands.py and _client_factory.py.

Reviewed changes

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

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/vm/operations/vm_host.py Adds a wrapper command class to customize AAZ vm host update argument schema/options.
src/azure-cli/azure/cli/command_modules/vm/custom.py Re-implements vm host create and vm host get-instance-view by calling AAZ Create/Show.
src/azure-cli/azure/cli/command_modules/vm/commands.py Removes SDK-based vm host command group wiring and registers AAZ-based update.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/_update.py Introduces generated AAZ implementation for vm host update.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/_show.py Updates generated Show to newer API version and expands enum/output schema.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/_create.py Introduces generated AAZ implementation used by the custom create_dedicated_host wrapper.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/host/__init__.py Exports new generated Create and Update classes.
src/azure-cli/azure/cli/command_modules/vm/_client_factory.py Removes unused dedicated host client factory.

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

if license_type:
command_args['license_type'] = license_type

if platform_fault_domain:
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

platform_fault_domain can legitimately be 0 (see _params.py allows 0,1,2), but this truthy check will skip adding it to command_args, changing behavior for az vm host create -d 0 and breaking existing tests/recordings. Use an explicit is not None check (and similarly avoid truthy checks for other numeric args).

Suggested change
if platform_fault_domain:
if platform_fault_domain is not None:

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +28
"version": "2022-11-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups/{}/hosts/{}", "2022-11-01"],
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

This generated Update command uses API version 2022-11-01, but other vm host operations (e.g. vm/host/_show.py and the existing vm host update test recordings) use 2024-11-01. This will change request URIs and may break playback tests and/or behavior. Align the _aaz_info resources and api-version query parameter to the same version used by the other dedicated host commands.

Suggested change
"version": "2022-11-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups/{}/hosts/{}", "2022-11-01"],
"version": "2024-11-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/hostgroups/{}/hosts/{}", "2024-11-01"],

Copilot uses AI. Check for mistakes.
)
_args_schema.expand = AAZStrArg(
options=["--expand"],
help="The expand expression to apply on the operation. 'InstanceView' will retrieve the list of instance views of the dedicated host. 'UserData' is not supported for dedicated host.",
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

The --expand help text still says only instanceView is supported and userData is not, but the enum now includes resiliencyView. Update the help text so it documents the newly supported value (and clarify any dedicated-host limitations).

Suggested change
help="The expand expression to apply on the operation. 'InstanceView' will retrieve the list of instance views of the dedicated host. 'UserData' is not supported for dedicated host.",
help="The expand expression to apply on the operation. 'instanceView' will retrieve the list of instance views of the dedicated host. 'resiliencyView' will retrieve the resiliency status of the dedicated host. For dedicated hosts, 'userData' is not supported.",

Copilot uses AI. Check for mistakes.
)
_args_schema.host_name = AAZStrArg(
options=["-n", "--name", "--host-name"],
help="The name of the dedicated host .",
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

Help string has an extra space before the period ("dedicated host ."), which shows up in -h output. Please fix the punctuation/spacing.

Suggested change
help="The name of the dedicated host .",
help="The name of the dedicated host.",

Copilot uses AI. Check for mistakes.
@william051200
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

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