Skip to content

{Compute} Clean up code#33297

Open
william051200 wants to merge 10 commits into
Azure:devfrom
william051200:clean-up-code-2
Open

{Compute} Clean up code#33297
william051200 wants to merge 10 commits into
Azure:devfrom
william051200:clean-up-code-2

Conversation

@william051200
Copy link
Copy Markdown
Member

Related command

Description

Refactored several lines of code to simplify future maintenance.

Testing Guide

History Notes


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings April 30, 2026 03:41
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented Apr 30, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

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

azure-client-tools-bot-prd Bot commented Apr 30, 2026

⚠️AzureCLI-BreakingChangeTest
⚠️vm
rule cmd_name rule_message suggest_message
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter expand: added property aaz_type=string
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter expand: added property choices=['instanceView']
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter expand: added property type=string
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter resource_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter resource_group_name: added property type=string
⚠️ 1010 - ParaPropUpdate restore-point wait cmd restore-point wait update parameter resource_group_name: updated property name from resource_group_name to resource_group
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter restore_point_collection_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter restore_point_collection_name: added property id_part=name
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter restore_point_collection_name: added property type=string
⚠️ 1010 - ParaPropUpdate restore-point wait cmd restore-point wait update parameter restore_point_collection_name: updated property options from ['--collection-name'] to ['--collection-name', '--restore-point-collection-name']
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter restore_point_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter restore_point_name: added property id_part=child_name_1
⚠️ 1008 - ParaPropAdd restore-point wait cmd restore-point wait update parameter restore_point_name: added property type=string

@github-actions
Copy link
Copy Markdown

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>

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 30, 2026

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

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

Refactors the VM command module registration and client factory usage in command_modules/vm to simplify code and reduce unused SDK command type scaffolding.

Changes:

  • Simplified list_vm_extension_images formatting in custom.py.
  • Removed multiple CliCommandType declarations and updated several command_group(...) registrations in commands.py.
  • Deleted a large set of unused client factory helpers in _client_factory.py.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/azure-cli/azure/cli/command_modules/vm/custom.py Minor formatting refactor of a helper command implementation.
src/azure-cli/azure/cli/command_modules/vm/commands.py Reworked imports and command group registrations to reduce SDK command type usage.
src/azure-cli/azure/cli/command_modules/vm/_client_factory.py Removed unused client factory functions to simplify the module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +10 to +15
cf_gallery_images, cf_gallery_image_versions,
cf_proximity_placement_groups,
cf_dedicated_hosts,
cf_vm_image, cf_vm_image_term, cf_usage,
cf_vmss, cf_images,
cf_dedicated_hosts, cf_dedicated_host_groups,
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

The _client_factory module no longer defines several names imported here (e.g., cf_vm_ext, cf_vm_ext_image, cf_gallery_images, cf_gallery_image_versions, cf_proximity_placement_groups, cf_images, cf_dedicated_host_groups). As-is, this will raise an ImportError when az loads the VM command module. Remove these imports or reintroduce the corresponding factory functions, and also deduplicate the repeated imports in this block.

Copilot uses AI. Check for mistakes.
Comment on lines +342 to +346
g.custom_command('get-instance-view', 'get_vmss_instance_view', table_transformer='{ProvisioningState:statuses[0].displayStatus, PowerState:statuses[1].displayStatus}')
g.custom_command('create', 'create_vmss', transform=DeploymentOutputLongRunningOperation(self.cli_ctx, 'Starting vmss create'), supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_vmss_create_namespace, exception_handler=handle_template_based_exception)
g.custom_show_command('show', 'get_vmss', table_transformer=get_vmss_table_output_transformer(self, False))
g.custom_command('stop', 'stop_vmss', supports_no_wait=True, validator=process_vm_vmss_stop)
g.generic_update_command('update', getter_name='get_vmss_modified_by_aaz', setter_name='update_vmss', supports_no_wait=True, command_type=compute_custom, validator=validate_vmss_update_namespace)
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

vmss commands like get-instance-view, create, show, stop, and update are being registered in two separate with self.command_group('vmss', ...) blocks (one without compute_vmss_sdk above, and this one). This will overwrite earlier registrations and can change behavior depending on load order. Consolidate these commands into a single vmss command group, or ensure each block registers distinct command names.

Suggested change
g.custom_command('get-instance-view', 'get_vmss_instance_view', table_transformer='{ProvisioningState:statuses[0].displayStatus, PowerState:statuses[1].displayStatus}')
g.custom_command('create', 'create_vmss', transform=DeploymentOutputLongRunningOperation(self.cli_ctx, 'Starting vmss create'), supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_vmss_create_namespace, exception_handler=handle_template_based_exception)
g.custom_show_command('show', 'get_vmss', table_transformer=get_vmss_table_output_transformer(self, False))
g.custom_command('stop', 'stop_vmss', supports_no_wait=True, validator=process_vm_vmss_stop)
g.generic_update_command('update', getter_name='get_vmss_modified_by_aaz', setter_name='update_vmss', supports_no_wait=True, command_type=compute_custom, validator=validate_vmss_update_namespace)

Copilot uses AI. Check for mistakes.
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.

4 participants