{Compute} az vm open-port: Migrate command to aaz-based implementation#32846
{Compute} az vm open-port: Migrate command to aaz-based implementation#32846william051200 wants to merge 3 commits intoAzure:devfrom
az vm open-port: Migrate command to aaz-based implementation#32846Conversation
️✔️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
This PR migrates the az vm open-port command from the legacy mgmt.compute SDK to the new aaz-based implementation. The migration updates the internal implementation to use aaz-based VM retrieval while maintaining the same command functionality.
Changes:
- Updated VM retrieval to use
get_vm_by_aazinstead ofget_vm - Modified property access patterns to use dictionary
.get()methods instead of object attribute access - Relocated the command registration to align with other aaz-based VM commands
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/vm/custom.py | Updated open_vm_port function to use aaz-based VM retrieval and dictionary-based property access |
| src/azure-cli/azure/cli/command_modules/vm/commands.py | Moved command registration from mgmt.compute SDK group to aaz-based command group |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| location = vm.location | ||
| vm = get_vm_by_aaz(cmd, resource_group_name, vm_name) | ||
| location = vm.get('location', '') | ||
| if not vm.network_profile: |
There was a problem hiding this comment.
After migrating to aaz-based implementation, vm is now a dictionary. This condition checks for the old object attribute network_profile which doesn't exist on dictionaries. This should be updated to vm.get('networkProfile') to match the new dictionary-based access pattern used elsewhere in this function.
| if not vm.network_profile: | |
| if not vm.get('networkProfile'): |
Related command
az vm open-portDescription
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.