{Compute} Migrate vm validator function of calling Compute module to aaz-based implementation#33530
Merged
Merged
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
microsoft-github-policy-service
Bot
requested review from
yonzhan and
zhoxing-ms
June 11, 2026 01:08
Contributor
There was a problem hiding this comment.
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_infohelper (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_infohelper 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) |
Collaborator
|
Compute |
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
yanzhudd
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related command
az vm snapshot createDescription
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.