-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Compute} disk command migration #32588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
❌AzureCLI-FullTest
|
|
Hi @william051200, |
️✔️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.
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 VM disk commands from the legacy mgmt.compute SDK to the newer AAZ (Azure CLI Auto-generation)-based approach. The migration affects the az disk create and az disk update commands.
Key Changes
- Replaced
resource_id()utility calls with AAZShowcommand invocations fordisk-encryption-setanddisk-accessresources to retrieve full resource IDs - Removed the
compute_disk_sdkparameter from the disk command group registration - Added a new
_validate_gallery_image_reference_by_aazvalidator function to replace the SDK-based version
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/vm/operations/disk.py |
Updated DiskUpdate class to use AAZ Show commands (DiskEncryptionSetShow, DiskAccessShow) instead of resource_id utility for resolving resource names to IDs |
src/azure-cli/azure/cli/command_modules/vm/custom.py |
Updated create_managed_disk function to use AAZ Show commands for disk_encryption_set, disk_access, and secure_vm_disk_encryption_set resolution |
src/azure-cli/azure/cli/command_modules/vm/commands.py |
Removed compute_disk_sdk parameter from disk command group, completing migration to AAZ-based commands |
src/azure-cli/azure/cli/command_modules/vm/_validators.py |
Added new _validate_gallery_image_reference_by_aaz function and commented out API version check in _validate_upload_type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # if not cmd.supported_api_version(min_api='2021-08-01', operation_group='disks'): | ||
| # raise ArgumentUsageError( | ||
| # "'UploadWithSecurityData' is not supported in the current profile. " | ||
| # "Please upgrade your profile with 'az cloud set --profile newerProfile' and try again") | ||
|
|
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented-out code should be removed. This API version check was commented out during the migration to AAZ, but commented code should not be left in production. If the check is no longer needed because AAZ handles API version compatibility automatically, remove these lines entirely. If the check is still needed, it should be uncommented and properly implemented for AAZ commands.
| # if not cmd.supported_api_version(min_api='2021-08-01', operation_group='disks'): | |
| # raise ArgumentUsageError( | |
| # "'UploadWithSecurityData' is not supported in the current profile. " | |
| # "Please upgrade your profile with 'az cloud set --profile newerProfile' and try again") |
| disk_encryption_set = DiskEncryptionSetShow(cli_ctx=self.cli_ctx)(command_args={ | ||
| 'resource_group': args.resource_group, | ||
| 'disk_encryption_set_name': disk_encryption_set | ||
| }) | ||
|
|
||
| if disk_encryption_set: | ||
| disk_encryption_set = disk_encryption_set['id'] | ||
| else: | ||
| disk_encryption_set = None |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for DiskEncryptionSetShow. AAZ Show commands raise HttpResponseError when the resource is not found, but this code doesn't catch that exception. The current code will fail with an unhandled exception if the disk encryption set doesn't exist. You should wrap this call in a try-except block to catch HttpResponseError, similar to the pattern used in get_network_lb in _validators.py (lines 1720-1726).
| disk_access = DiskAccessShow(cli_ctx=self.cli_ctx)(command_args={ | ||
| 'resource_group': args.resource_group, | ||
| 'disk_access_name': disk_access | ||
| }) | ||
|
|
||
| if disk_access: | ||
| disk_access = disk_access['id'] | ||
| else: | ||
| disk_access = None |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for DiskAccessShow. AAZ Show commands raise HttpResponseError when the resource is not found, but this code doesn't catch that exception. The current code will fail with an unhandled exception if the disk access doesn't exist. You should wrap this call in a try-except block to catch HttpResponseError, similar to the pattern used in get_network_lb in _validators.py (lines 1720-1726).
| disk_access = disk_access['id'] | ||
| else: | ||
| disk_access = None | ||
|
|
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected on this line. Please remove it.
| disk_encryption_set = DiskEncryptionSetShow(cli_ctx=cmd.cli_ctx)(command_args={ | ||
| 'resource_group': resource_group_name, | ||
| 'disk_encryption_set_name': disk_encryption_set | ||
| }) | ||
|
|
||
| if disk_encryption_set: | ||
| disk_encryption_set = disk_encryption_set['id'] | ||
| else: | ||
| disk_encryption_set = None |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for DiskEncryptionSetShow. AAZ Show commands raise HttpResponseError when the resource is not found, but this code doesn't catch that exception. The current code will fail with an unhandled exception if the disk encryption set doesn't exist. You should wrap this call in a try-except block to catch HttpResponseError, similar to the pattern used in get_network_lb in _validators.py (lines 1720-1726).
| disk_access = DiskAccessShow(cli_ctx=cmd.cli_ctx)(command_args={ | ||
| 'resource_group': resource_group_name, | ||
| 'disk_access_name': disk_access | ||
| }) | ||
|
|
||
| if disk_access: | ||
| disk_access = disk_access['id'] | ||
| else: | ||
| disk_access = None |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for DiskAccessShow. AAZ Show commands raise HttpResponseError when the resource is not found, but this code doesn't catch that exception. The current code will fail with an unhandled exception if the disk access doesn't exist. You should wrap this call in a try-except block to catch HttpResponseError, similar to the pattern used in get_network_lb in _validators.py (lines 1720-1726).
| secure_vm_disk_encryption_set = DiskEncryptionSetShow(cli_ctx=cmd.cli_ctx)(command_args={ | ||
| 'resource_group': resource_group_name, | ||
| 'disk_encryption_set_name': secure_vm_disk_encryption_set | ||
| }) | ||
|
|
||
| if secure_vm_disk_encryption_set: | ||
| secure_vm_disk_encryption_set = secure_vm_disk_encryption_set['id'] | ||
| else: | ||
| secure_vm_disk_encryption_set = None |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for DiskEncryptionSetShow. AAZ Show commands raise HttpResponseError when the resource is not found, but this code doesn't catch that exception. The current code will fail with an unhandled exception if the secure VM disk encryption set doesn't exist. You should wrap this call in a try-except block to catch HttpResponseError, similar to the pattern used in get_network_lb in _validators.py (lines 1720-1726).
Related command
az disk createaz disk updateDescription
Migration from mgmt.compute to aaz-based
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.