{Serial Console} Migrate commands calling Compute module to aaz-based implementation#9781
{Serial Console} Migrate commands calling Compute module to aaz-based implementation#9781william051200 wants to merge 6 commits intoAzure:mainfrom
Conversation
️✔️Azure CLI Extensions Breaking Change Test
|
|
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 serial-console extension’s compute-related operations from azure.mgmt.compute client usage to Azure CLI’s AAZ-based compute command implementations, and publishes the migration as a new stable extension release.
Changes:
- Switch VM/VMSS lookups in
custom.pyto AAZ-based command execution and update parsing to dictionary-style responses. - Remove the compute management client factory no longer needed after the migration.
- Bump extension version and add release notes for the migration.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/serial-console/setup.py |
Bumps the extension version to 1.1.0. |
src/serial-console/azext_serialconsole/custom.py |
Migrates VM/VMSS compute calls to AAZ-based command usage and updates instance view parsing/error handling. |
src/serial-console/azext_serialconsole/_client_factory.py |
Removes the legacy compute client factory. |
src/serial-console/HISTORY.rst |
Adds 1.1.0 release entry documenting the migration. |
| except HttpResponseError as e: | ||
| try: | ||
| client.virtual_machine_scale_sets.get(resource_group_name, vm_vmss_name) | ||
| except ComputeClientResourceNotFoundError: | ||
| command_args = { | ||
| 'resource_group': resource_group_name, | ||
| 'vm_scale_set_name': vm_vmss_name | ||
| } | ||
| VMSSShow(cli_ctx=cli_ctx)(command_args=command_args) | ||
| except HttpResponseError: | ||
| raise e from e | ||
| error_message = e.message | ||
| recommendation = ("We found that you specified a Virtual Machine Scale Set and not a VM. " | ||
| "Use the --instance-id parameter to select the VMSS instance you want to connect to.") | ||
| raise ResourceNotFoundError( | ||
| error_message, recommendation=recommendation) from e | ||
| raise ResourceNotFoundError(error_message, recommendation=recommendation) from e |
There was a problem hiding this comment.
The except HttpResponseError block will also catch non-404 failures (authz, throttling, transient network issues). In those cases, the code may incorrectly treat the VM lookup failure as a VMSS/VM mix-up and raise a ResourceNotFoundError with a misleading recommendation. Narrow the handler to azure.core.exceptions.ResourceNotFoundError (or check the HTTP status code == 404) and re-raise other HttpResponseErrors unchanged.
| @@ -704,40 +701,44 @@ def get_region_from_storage_account(cli_ctx, resource_group_name, vm_vmss_name, | |||
| 'MyScaleSet -g MyResourceGroup --instance-ids *".') | |||
There was a problem hiding this comment.
The recommendation command string has an extra trailing quote after the JSON payload (...StorageUri\" : null}}\"\" ...), which makes the suggested az vmss update --set ... command invalid / hard to copy-paste. Remove the redundant quote so the JSON string is quoted exactly once in the rendered command.
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
1 similar comment
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
c250c6e to
9a4683b
Compare
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
1 similar comment
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
54ddf62 to
53a72c5
Compare
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Migration from mgmt.compute to aaz-based
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install wheel==0.30.0required)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.