Skip to content

{Compute} az capacity reservation: Migrate to Code Gen based#31794

Merged
zhoxing-ms merged 2 commits intoAzure:devfrom
yanzhudd:migrate-capacity-reservation
Jul 11, 2025
Merged

{Compute} az capacity reservation: Migrate to Code Gen based#31794
zhoxing-ms merged 2 commits intoAzure:devfrom
yanzhudd:migrate-capacity-reservation

Conversation

@yanzhudd
Copy link
Copy Markdown
Contributor

@yanzhudd yanzhudd commented Jul 11, 2025

Related command

az capacity reservation create/update/show

Description

aaz PR: Azure/aaz#806

Testing Guide

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


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

@yanzhudd yanzhudd self-assigned this Jul 11, 2025
Copilot AI review requested due to automatic review settings July 11, 2025 05:18
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented Jul 11, 2025

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

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

azure-client-tools-bot-prd Bot commented Jul 11, 2025

❌AzureCLI-BreakingChangeTest
❌vm
rule cmd_name rule_message suggest_message
1006 - ParaAdd capacity reservation delete cmd capacity reservation delete added parameter capacity_reservation_group please remove parameter capacity_reservation_group for cmd capacity reservation delete
1007 - ParaRemove capacity reservation delete cmd capacity reservation delete removed parameter capacity_reservation_group_name please add back parameter capacity_reservation_group_name for cmd capacity reservation delete
1006 - ParaAdd capacity reservation list cmd capacity reservation list added parameter capacity_reservation_group please remove parameter capacity_reservation_group for cmd capacity reservation list
1007 - ParaRemove capacity reservation list cmd capacity reservation list removed parameter capacity_reservation_group_name please add back parameter capacity_reservation_group_name for cmd capacity reservation list
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter capacity_reservation_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter capacity_reservation_group_name: added property type=string
⚠️ 1010 - ParaPropUpdate capacity reservation create cmd capacity reservation create update parameter capacity_reservation_group_name: updated property name from capacity_reservation_group_name to capacity_reservation_group
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter capacity_reservation_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter capacity_reservation_name: added property type=string
⚠️ 1010 - ParaPropUpdate capacity reservation create cmd capacity reservation create update parameter capacity_reservation_name: updated property options from ['--capacity-reservation-name', '-n'] to ['--capacity-reservation-name', '--name', '-n']
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter capacity: added property aaz_type=int
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter location: added property aaz_type=string
⚠️ 1010 - ParaPropUpdate capacity reservation create cmd capacity reservation create update parameter location: updated property type from custom_type to string
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter no_wait: added property aaz_type=bool
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter no_wait: added property choices=['0', '1', 'f', 'false', 'n', 'no', 't', 'true', 'y', 'yes']
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter no_wait: added property nargs=?
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter no_wait: added property type=bool
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter resource_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter resource_group_name: added property type=string
⚠️ 1010 - ParaPropUpdate capacity reservation create cmd capacity reservation create update parameter resource_group_name: updated property name from resource_group_name to resource_group
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter sku_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter sku_name: added property type=string
⚠️ 1009 - ParaPropRemove capacity reservation create cmd capacity reservation create update parameter sku_name: removed property required=True
⚠️ 1010 - ParaPropUpdate capacity reservation create cmd capacity reservation create update parameter sku_name: updated property name from sku_name to sku
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter tags: added property aaz_type=AAZDictArg
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter tags: added property type=Dict<String,String>
⚠️ 1010 - ParaPropUpdate capacity reservation create cmd capacity reservation create update parameter tags: updated property nargs from * to +
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter zone: added property aaz_type=AAZListArg
⚠️ 1008 - ParaPropAdd capacity reservation create cmd capacity reservation create update parameter zone: added property type=List<String>
⚠️ 1010 - ParaPropUpdate capacity reservation create cmd capacity reservation create update parameter zone: updated property nargs from 1 to +
⚠️ 1006 - ParaAdd capacity reservation list cmd capacity reservation list added parameter pagination_limit
⚠️ 1006 - ParaAdd capacity reservation list cmd capacity reservation list added parameter pagination_token
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter capacity_reservation_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter capacity_reservation_group_name: added property id_part=name
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter capacity_reservation_group_name: added property type=string
⚠️ 1010 - ParaPropUpdate capacity reservation show cmd capacity reservation show update parameter capacity_reservation_group_name: updated property name from capacity_reservation_group_name to capacity_reservation_group
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter capacity_reservation_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter capacity_reservation_name: added property id_part=child_name_1
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter capacity_reservation_name: added property type=string
⚠️ 1010 - ParaPropUpdate capacity reservation show cmd capacity reservation show update parameter capacity_reservation_name: updated property options from ['--capacity-reservation-name', '-n'] to ['--capacity-reservation-name', '--name', '-n']
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter instance_view: added property aaz_type=bool
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter instance_view: added property choices=['0', '1', 'f', 'false', 'n', 'no', 't', 'true', 'y', 'yes']
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter instance_view: added property nargs=?
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter instance_view: added property type=bool
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter resource_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd capacity reservation show cmd capacity reservation show update parameter resource_group_name: added property type=string
⚠️ 1010 - ParaPropUpdate capacity reservation show cmd capacity reservation show update parameter resource_group_name: updated property name from resource_group_name to resource_group
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter capacity_reservation_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter capacity_reservation_group_name: added property id_part=name
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter capacity_reservation_group_name: added property type=string
⚠️ 1010 - ParaPropUpdate capacity reservation update cmd capacity reservation update update parameter capacity_reservation_group_name: updated property name from capacity_reservation_group_name to capacity_reservation_group
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter capacity_reservation_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter capacity_reservation_name: added property id_part=child_name_1
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter capacity_reservation_name: added property type=string
⚠️ 1010 - ParaPropUpdate capacity reservation update cmd capacity reservation update update parameter capacity_reservation_name: updated property options from ['--capacity-reservation-name', '-n'] to ['--capacity-reservation-name', '--name', '-n']
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter capacity: added property aaz_type=int
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter no_wait: added property aaz_type=bool
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter no_wait: added property choices=['0', '1', 'f', 'false', 'n', 'no', 't', 'true', 'y', 'yes']
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter no_wait: added property nargs=?
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter no_wait: added property type=bool
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter resource_group_name: added property aaz_type=string
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter resource_group_name: added property type=string
⚠️ 1010 - ParaPropUpdate capacity reservation update cmd capacity reservation update update parameter resource_group_name: updated property name from resource_group_name to resource_group
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter tags: added property aaz_type=AAZDictArg
⚠️ 1008 - ParaPropAdd capacity reservation update cmd capacity reservation update update parameter tags: added property type=Dict<String,String>
⚠️ 1010 - ParaPropUpdate capacity reservation update cmd capacity reservation update update parameter tags: updated property nargs from * to +
⚠️ 1001 - CmdAdd capacity reservation wait cmd capacity reservation wait added

Please submit your Breaking Change Pre-announcement ASAP if you haven't already. Please note:

  • Breaking changes can only be merged during the designated breaking change window
  • A pre-announcement must be released at least one month in advance

For more details on how to introduce breaking changes, refer to the documentation: azure-cli/doc/how_to_introduce_breaking_changes.md

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Jul 11, 2025

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

@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>

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 capacity reservation commands (az capacity reservation) from manual implementation to code generation (AAZ) based approach. The migration includes updating test methods to comprehensively test the create/update/show operations for capacity reservations and moving from the old centraluseuap region to eastus2euap.

Key Changes

  • Migrated capacity reservation commands to use AAZ-based code generation
  • Added comprehensive test coverage for capacity reservation create/update/show operations
  • Updated test location from centraluseuap to eastus2euap

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

File Description
test_vm_commands.py Renamed and expanded test function to cover create/update/show operations
test_capacity_reservation_operations.yaml New recording file for the expanded test operations
test_capacity_reservation_list_delete.yaml Removed old recording file (deleted)
capacity_reservation.py New AAZ-based implementation for update and show operations
Comments suppressed due to low confidence (1)

Comment on lines +27 to +32
instance = _CapacityReservationShow(cli_ctx=self.cli_ctx)(command_args={
"capacity_reservation_group": args.capacity_reservation_group,
"capacity_reservation_name": args.capacity_reservation_name,
"resource_group": args.resource_group,
})
args.tags = instance.get("tags", None)
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

Consider handling potential exceptions from the Show command execution. If the show operation fails, the update operation would fail with an unclear error. Add proper error handling to provide better user experience.

Suggested change
instance = _CapacityReservationShow(cli_ctx=self.cli_ctx)(command_args={
"capacity_reservation_group": args.capacity_reservation_group,
"capacity_reservation_name": args.capacity_reservation_name,
"resource_group": args.resource_group,
})
args.tags = instance.get("tags", None)
try:
instance = _CapacityReservationShow(cli_ctx=self.cli_ctx)(command_args={
"capacity_reservation_group": args.capacity_reservation_group,
"capacity_reservation_name": args.capacity_reservation_name,
"resource_group": args.resource_group,
})
args.tags = instance.get("tags", None)
except Exception as ex:
logger.error("Failed to retrieve capacity reservation details: %s", str(ex))
raise RuntimeError("Unable to retrieve capacity reservation details. Please check the provided arguments and try again.") from ex

Copilot uses AI. Check for mistakes.
@zhoxing-ms zhoxing-ms merged commit 6493581 into Azure:dev Jul 11, 2025
59 checks passed
@yanzhudd yanzhudd deleted the migrate-capacity-reservation branch July 11, 2025 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

5 participants