{Compute} az vmss/vm: Update Open Capacity Reservation validation to support 'None' - #34072
Merged
Julie Zhu (yanzhudd) merged 1 commit intoSep 14, 2026
Merged
Conversation
microsoft-github-policy-service
Bot
requested review from
Julie Zhu (yanzhudd) and
Yong Zhang (yonzhan)
September 14, 2026 01:26
Copilot started reviewing on behalf of
William (william051200)
September 14, 2026 01:27
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The VM update path must omit the capacity reservation group when None is used with disabled assignment.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates VM and VMSS capacity reservation validation and payload construction to support None when assignment is disabled.
Changes:
- Relaxes validation for the
Nonesentinel. - Centralizes capacity reservation profile construction.
- Omits capacity reservation groups when appropriate.
File summaries
| File | Summary and review findings |
|---|---|
src/azure-cli/azure/cli/command_modules/vm/_validators.py |
Updates validation rules. Missing command-level regression coverage (nit, 1 vote). VM update still emits an empty capacity reservation group for None with disabled assignment (moderate, 1 vote). |
src/azure-cli/azure/cli/command_modules/vm/_template_builder.py |
Adds shared profile construction. Missing focused unit coverage for sentinel, boolean, and omitted-value cases (nit, 3 votes). |
Review details
Suppressed comments (2)
src/azure-cli/azure/cli/command_modules/vm/_validators.py:2836
- This changes the acceptance rule for all four create/update commands, but the repository has no regression test for the newly allowed combination (
--capacity-reservation-group Nonewith--disable-capacity-reservation-assignment true) or for rejecting a real group with the flag. The existing open-capacity scenario only exercises the flag without the group. Please add command-level coverage for both the accepted sentinel case and the still-invalid real-group case.
if (namespace.disable_capacity_reservation_assignment is True and
namespace.capacity_reservation_group is not None and
namespace.capacity_reservation_group != 'None'):
src/azure-cli/azure/cli/command_modules/vm/_validators.py:2836
- This newly permits
vm update --capacity-reservation-group None --disable-capacity-reservation-assignment true, but the VM update path still convertsNoneintocapacity_reservation_group: {"id": None}and does not remove that field (the VMSS update path does). The generated PUT therefore contains an emptycapacityReservationGroupalongsidedisableCapacityReservationAssignment=true, so the advertised combination can still be rejected by Compute. Mirror the VMSS cleanup so the group object is omitted when disable is true.
if (namespace.disable_capacity_reservation_assignment is True and
namespace.capacity_reservation_group is not None and
namespace.capacity_reservation_group != 'None'):
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+296
to
+301
| def _build_capacity_reservation_profile(capacity_reservation_group, disable_assignment): | ||
| profile = {} | ||
| if capacity_reservation_group and capacity_reservation_group != 'None': | ||
| profile['capacityReservationGroup'] = {'id': capacity_reservation_group} | ||
| if disable_assignment is not None: | ||
| profile['disableCapacityReservationAssignment'] = disable_assignment |
Collaborator
|
Compute |
Julie Zhu (yanzhudd)
approved these changes
Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 PR Validation — ️✔️ All clear
Related command
az vm create/updateaz vmss create/updateDescription
Update the command to support None as input, eg:
capacity reservation groupis None +disable capacity reservation groupis True = AllowedTesting Guide
History Notes
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.