{sqlvm} Migrate validator function from calling Compute module to aaz-based implementation#32964
{sqlvm} Migrate validator function from calling Compute module to aaz-based implementation#32964william051200 wants to merge 3 commits intoAzure:devfrom
Conversation
❌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 the SQL VM Azure AD auth validator away from the mgmt.compute SDK usage into an AAZ-based VM retrieval path, with updated test recordings to reflect the new underlying Compute API version.
Changes:
- Replaced
ResourceType.MGMT_COMPUTEclient usage withVMShow(AAZ) to fetch VM identity data. - Updated VM identity parsing to use dict/camelCase fields (
principalId,userAssignedIdentities, etc.). - Refreshed test recordings to use a newer Compute
api-version.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/sqlvm/_validators.py | Switches VM lookup from mgmt SDK to AAZ VMShow and updates identity field access accordingly. |
| src/azure-cli/azure/cli/command_modules/sqlvm/tests/latest/recordings/test_sqlvm_aad_auth_negative.yaml | Updates recorded Compute VM GET requests to a newer api-version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
| from azure.cli.core.profiles import ResourceType | ||
| compute_client = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_COMPUTE) | ||
| from ..vm.operations.vm import VMShow |
| vm = VMShow(cli_ctx=cli_ctx)(command_args={ | ||
| 'resource_group': namespace.resource_group_name, | ||
| 'vm_name': namespace.sql_virtual_machine_name | ||
| }) |
| for umi in vm['identity']['userAssignedIdentities'].keys(): | ||
| if vm['identity']['userAssignedIdentities'][umi]['clientId'] == namespace.msi_client_id: | ||
| return vm['identity']['userAssignedIdentities'][umi]['principalId'] |
Related command
sql vm enable-azure-ad-authsql vm validate-azure-ad-authDescription
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.