Skip to content

{Compute} az capacity reservation group: Migrate command group to aaz-based implementation#32910

Open
william051200 wants to merge 12 commits intoAzure:devfrom
william051200:capacity-reservation-group-migration
Open

{Compute} az capacity reservation group: Migrate command group to aaz-based implementation#32910
william051200 wants to merge 12 commits intoAzure:devfrom
william051200:capacity-reservation-group-migration

Conversation

@william051200
Copy link
Copy Markdown
Member

Related command

az capacity reservation group create
az capacity reservation group update
az capacity reservation group show

Description

Migration from mgmt.compute to aaz-based

aaz Azure/aaz#954

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 March 5, 2026 06:50
@william051200 william051200 requested a review from yanzhudd as a code owner March 5, 2026 06:50
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Mar 5, 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 Mar 5, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 5, 2026

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 Mar 5, 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

Migrates az capacity reservation group’s create/update/show implementations in the VM command module from the Compute management SDK path to AAZ-based commands, aligning with ongoing AAZ adoption in this area of the codebase.

Changes:

  • Replaced SDK client usage in create_capacity_reservation_group, update_capacity_reservation_group, and show_capacity_reservation_group with calls into AAZ command classes.
  • Updated command registration for capacity reservation group to remove the SDK command type/client factory wiring.
  • Added generated AAZ command implementations for capacity reservation group create/show/update and exported them from the AAZ package.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/vm/custom.py Switches create/update/show custom handlers to invoke AAZ commands and adapts argument shaping (e.g., sharing profile).
src/azure-cli/azure/cli/command_modules/vm/commands.py Registers capacity reservation group commands without SDK command_type/client_factory.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/capacity/reservation/group/_create.py Adds generated AAZ Create command for capacity reservation groups.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/capacity/reservation/group/_show.py Adds generated AAZ Show command for capacity reservation groups.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/capacity/reservation/group/_update.py Adds generated AAZ Update command for capacity reservation groups.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/capacity/reservation/group/__init__.py Exports the new generated AAZ commands from the package.

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



class Create(AAZCommand):
"""Create operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details.
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

The Create command docstring says "When updating a capacity reservation group, only tags may be modified", but this command also accepts and sends zones and sharing_profile. Please update the generated description to avoid misleading future maintainers about what this command actually supports.

Suggested change
"""Create operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details.
"""Create operation to create or update a capacity reservation group. Please refer to https://aka.ms/CapacityReservation for more details.

Copilot uses AI. Check for mistakes.


class Update(AAZCommand):
"""Update operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details.
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

The Update command docstring says "only tags may be modified", but this command schema and JSON update logic also handle sharing_profile (and even exposes zones). Please update the description (or regenerate from the correct swagger) so the documentation matches the supported update surface.

Suggested change
"""Update operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details.
"""Update operation to create or update a capacity reservation group. When updating a capacity reservation group, you can modify tags and other updatable properties. Please refer to https://aka.ms/CapacityReservation for more details.

Copilot uses AI. Check for mistakes.
Comment on lines +6278 to +6280
if tags:
command_args['tags'] = tags

Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

update_capacity_reservation_group only forwards tags when it is truthy. This breaks the common CLI behavior of clearing tags via --tags "", which is parsed as an empty dict and should be sent to the service to remove existing tags. Use an explicit tags is not None check (and forward empty dicts) so tag clearing continues to work after the AAZ migration.

Copilot uses AI. Check for mistakes.

with self.command_group('capacity reservation group', capacity_reservation_groups_sdk, min_api='2021-04-01',
client_factory=cf_capacity_reservation_groups) as g:
with self.command_group('capacity reservation group') as g:
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

The command group no longer uses capacity_reservation_groups_sdk / cf_capacity_reservation_groups, so the capacity_reservation_groups_sdk = CliCommandType(...) definition (and the corresponding import) in this module become unused and may trigger lint failures. Remove the unused CliCommandType and import, or rewire the command group to use them if still needed.

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

act-observability-squad Auto-Assign Auto assign by bot Compute az vm/vmss/image/disk/snapshot Reservations az reservations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants