{Backup} az backup protection: Migrate commands calling Compute module to aaz-based implementation#32947
{Backup} az backup protection: Migrate commands calling Compute module to aaz-based implementation#32947william051200 wants to merge 2 commits intoAzure:devfrom
az backup protection: Migrate commands calling Compute module to aaz-based implementation#32947Conversation
❌AzureCLI-FullTest
|
️✔️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.
Pull request overview
Migrates az backup protection check-vm and az backup protection enable-for-vm away from azure.mgmt.compute VM lookups to the VM AAZ VMShow implementation, removing the backup module’s dependency on the Compute management client factory.
Changes:
- Replace
virtual_machines_cf(...).get(...)VM retrievals withVMShow(cli_ctx=...)(command_args=...)in backup protection flows. - Remove the Compute client factory (
_compute_client_factory) andvirtual_machines_cffrombackup/_client_factory.py. - Adjust VM field access to dict-style (
vm.get(...),vm['type']) based on AAZ output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/backup/custom.py |
Switches VM lookups in backup protection commands to AAZ VMShow and updates property access accordingly. |
src/azure-cli/azure/cli/command_modules/backup/_client_factory.py |
Removes now-unused Compute client factory helpers from the backup module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| vm = VMShow(cli_ctx=cmd.cli_ctx)(command_args={ | ||
| 'resource_group': vm_rg, | ||
| 'vm_name': vm_name | ||
| }).get('id') |
There was a problem hiding this comment.
In check_protection_enabled_for_vm, the second VMShow(...) call assigns vm to ...get('id'), so vm becomes a string. The next line calls vm.get('location'), which will raise AttributeError at runtime. Keep the full VM dict from VMShow (don’t .get('id') here), and read location from that response (or reuse the first VMShow result when available).
| }).get('id') | |
| }) |
Related command
az backup protection check-vmaz backup protection enable-for-vmDescription
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.