Skip to content

{Compute} Migrate vm validator function of calling Compute module to aaz-based implementation#33530

Merged
yanzhudd merged 4 commits into
Azure:devfrom
william051200:vm-validator-migration
Jun 16, 2026
Merged

{Compute} Migrate vm validator function of calling Compute module to aaz-based implementation#33530
yanzhudd merged 4 commits into
Azure:devfrom
william051200:vm-validator-migration

Conversation

@william051200

Copy link
Copy Markdown
Member

Related command

az vm snapshot create

Description

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 NoriZC as a code owner June 11, 2026 01:07
Copilot AI review requested due to automatic review settings June 11, 2026 01:07
@azure-client-tools-bot-prd

azure-client-tools-bot-prd Bot commented Jun 11, 2026

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

@azure-client-tools-bot-prd

azure-client-tools-bot-prd Bot commented Jun 11, 2026

Copy link
Copy Markdown
️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 VM module’s snapshot creation validation logic (used by az vm snapshot create) from the legacy Compute SDK client approach to an AAZ-based implementation, aligning validator behavior with the AAZ command layer.

Changes:

  • Replace disk/snapshot lookup in snapshot-related validation with _get_disk_or_snapshot_info_by_aaz.
  • Adjust downstream access patterns from SDK model attributes (e.g., .id, .location) to dict-style fields (e.g., .get('id'), .get('location')).
  • Remove the legacy _get_disk_or_snapshot_info helper (Compute SDK client-based).
Comments suppressed due to low confidence (1)

src/azure-cli/azure/cli/command_modules/vm/_validators.py:2270

  • The legacy _get_disk_or_snapshot_info helper was removed, but the module still imports _compute_client_factory (used only by that helper). This now appears to be an unused import and may trigger lint/pylint failures. Please remove the unused import at the top of this file.
def _get_disk_or_snapshot_info_by_aaz(cli_ctx, resource_group_name, source):
    from .aaz.latest.snapshot import Show as SnapshotShow
    from .aaz.latest.disk import Show as DiskShow
    is_snapshot = True

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

Comment on lines 2149 to 2153
try:
source_info, _ = _get_disk_or_snapshot_info(cmd.cli_ctx,
source_info, _ = _get_disk_or_snapshot_info_by_aaz(cmd.cli_ctx,
result['resource_group'],
result['name'])
except Exception: # pylint: disable=broad-except
Comment on lines 2219 to 2240
def _figure_out_storage_source(cli_ctx, resource_group_name, source):
source_blob_uri = None
source_disk = None
source_snapshot = None
source_info = None
source_restore_point = None
if urlparse(source).scheme: # a uri?
source_blob_uri = source
elif '/disks/' in source.lower():
source_disk = source
elif '/snapshots/' in source.lower():
source_snapshot = source
elif '/restorepoints/' in source.lower():
source_restore_point = source
else:
source_info, is_snapshot = _get_disk_or_snapshot_info(cli_ctx, resource_group_name, source)
source_info, is_snapshot = _get_disk_or_snapshot_info_by_aaz(cli_ctx, resource_group_name, source)
if is_snapshot:
source_snapshot = source_info.id
source_snapshot = source_info.get('id')
else:
source_disk = source_info.id
source_disk = source_info.get('id')

return (source_blob_uri, source_disk, source_snapshot, source_restore_point, source_info)
@yonzhan

yonzhan commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Compute

@yanzhudd

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd
yanzhudd merged commit 825b1a1 into Azure:dev Jun 16, 2026
50 checks passed
@william051200
william051200 deleted the vm-validator-migration branch June 16, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad 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