{Compute} az vmss extension: Migrate command group to aaz-based implementation#33337
{Compute} az vmss extension: Migrate command group to aaz-based implementation#33337william051200 wants to merge 11 commits into
az vmss extension: Migrate command group to aaz-based implementation#33337Conversation
️✔️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 az vmss extension command group in the VM command module from azure-mgmt-compute SDK usage to AAZ-based implementations, aligning VMSS extension operations with the newer AAZ patterns already used elsewhere in command_modules/vm.
Changes:
- Reworked VMSS extension delete/show/list/set to use AAZ VMSS show + AAZ VMSS update flows (with snake_case conversion for update payloads).
- Switched
vmss extension upgradeto an AAZ-generated rolling upgrade command. - Updated command registration for
vmss extensionto remove the compute SDK command group binding and removed themin_apigate onupgrade.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/vm/custom.py |
Migrates VMSS extension CRUD operations to AAZ; builds update payloads via convert_show_result_to_snake_case and invokes AAZ vmss Update. |
src/azure-cli/azure/cli/command_modules/vm/commands.py |
Updates vmss extension command group registration for AAZ migration and adjusts the upgrade registration. |
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vmss/extension/_rolling_upgrade.py |
Adds AAZ-generated implementation for VMSS extension rolling upgrade. |
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vmss/extension/__init__.py |
Exposes the new rolling upgrade command via package exports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| x.get('type_properties_type', '').lower() != extension_name.lower() | ||
| or x.get('publisher').lower() != publisher.lower()] |
| @@ -5283,102 +5283,109 @@ def detach_disk_from_vmss(cmd, resource_group_name, vmss_name, lun, instance_id= | |||
|
|
|||
| # region VirtualMachineScaleSets Extensions | |||
| def delete_vmss_extension(cmd, resource_group_name, vmss_name, extension_name): | |||
| g.custom_command('set', 'set_vmss_extension', supports_no_wait=True) | ||
| g.custom_command('list', 'list_vmss_extensions') | ||
| g.custom_command('upgrade', 'upgrade_vmss_extension', min_api='2020-06-01', supports_no_wait=True) | ||
| g.custom_command('upgrade', 'upgrade_vmss_extension', supports_no_wait=True) |
| with self.command_group('vmss extension') as g: | ||
| g.custom_command('delete', 'delete_vmss_extension', supports_no_wait=True) | ||
| g.custom_show_command('show', 'get_vmss_extension') | ||
| g.custom_command('set', 'set_vmss_extension', supports_no_wait=True) |
| if extension_profile: | ||
| extensions = extension_profile.extensions | ||
| extensions = extension_profile.get('extensions') | ||
| if extensions: | ||
| extension_profile.extensions = [x for x in extensions if | ||
| x.type_properties_type.lower() != extension_name.lower() or x.publisher.lower() != publisher.lower()] # pylint: disable=line-too-long | ||
|
|
||
| if cmd.supported_api_version(min_api='2019-07-01', operation_group='virtual_machine_scale_sets'): | ||
| ext = VirtualMachineScaleSetExtension(name=extension_instance_name, | ||
| publisher=publisher, | ||
| type_properties_type=extension_name, | ||
| protected_settings=protected_settings, | ||
| type_handler_version=version, | ||
| settings=settings, | ||
| auto_upgrade_minor_version=(not no_auto_upgrade), | ||
| provision_after_extensions=provision_after_extensions, | ||
| enable_automatic_upgrade=enable_auto_upgrade) | ||
| else: | ||
| ext = VirtualMachineScaleSetExtension(name=extension_instance_name, | ||
| publisher=publisher, | ||
| type=extension_name, | ||
| protected_settings=protected_settings, | ||
| type_handler_version=version, | ||
| settings=settings, | ||
| auto_upgrade_minor_version=(not no_auto_upgrade), | ||
| provision_after_extensions=provision_after_extensions, | ||
| enable_automatic_upgrade=enable_auto_upgrade) | ||
| extension_profile['extensions'] = \ | ||
| [x for x in extensions if | ||
| x.get('type_properties_type', '').lower() != extension_name.lower() | ||
| or x.get('publisher').lower() != publisher.lower()] | ||
|
|
| if vmss.get('virtualMachineProfile', {}).get('storageProfile', {}): | ||
| vmss['virtualMachineProfile']['storageProfile']['imageReference'] = None |
There was a problem hiding this comment.
| if vmss.get('virtualMachineProfile', {}).get('storageProfile', {}): | |
| vmss['virtualMachineProfile']['storageProfile']['imageReference'] = None | |
| if 'virtualMachineProfile' not in vmss: | |
| vmss['virtualMachineProfile'] = {} | |
| if 'storageProfile' not in vmss['virtualMachineProfile']: | |
| vmss['virtualMachineProfile']['storageProfile'] = {} | |
| vmss['virtualMachineProfile']['storageProfile']['imageReference'] = None |
| vmss['resource_group'] = resource_group_name | ||
| vmss['vm_scale_set_name'] = vmss_name | ||
|
|
||
| return VMSSUpdate(cli_ctx=cmd.cli_ctx)(command_args=vmss) |
There was a problem hiding this comment.
Is it better to use VMSSCreate rather than VMSSUpdate?
Related command
az vmss extension deleteaz vmss extension showaz vmss extension setaz vmss extension listaz vmss extension upgradeDescription
Migration from mgmt.compute to aaz-based
aaz Azure/aaz#1003
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.