Skip to content

{Serial Console} Migrate commands calling Compute module to aaz-based implementation#9781

Open
william051200 wants to merge 6 commits intoAzure:mainfrom
william051200:serial-console-migration
Open

{Serial Console} Migrate commands calling Compute module to aaz-based implementation#9781
william051200 wants to merge 6 commits intoAzure:mainfrom
william051200:serial-console-migration

Conversation

@william051200
Copy link
Copy Markdown
Member

@william051200 william051200 commented Apr 14, 2026

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

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

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.json automatically.
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.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Apr 14, 2026

️✔️Azure CLI Extensions Breaking Change Test
️✔️Non Breaking Changes

Copilot AI review requested due to automatic review settings April 14, 2026 05:35
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 14, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown
Contributor

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py to 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.

Comment on lines +718 to +730
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
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 696 to 701
@@ -704,40 +701,44 @@ def get_region_from_storage_account(cli_ctx, resource_group_name, vm_vmss_name,
'MyScaleSet -g MyResourceGroup --instance-ids *".')
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 2 pipeline(s).

1 similar comment
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 2 pipeline(s).

@william051200 william051200 force-pushed the serial-console-migration branch from c250c6e to 9a4683b Compare April 15, 2026 02:02
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 2 pipeline(s).

1 similar comment
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 2 pipeline(s).

@william051200 william051200 force-pushed the serial-console-migration branch from 54ddf62 to 53a72c5 Compare April 16, 2026 01:08
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 2 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants