Skip to content

{Compute} az capacity reservation/az capacity reservation group/az vm: Support Open Capacity Reservation - #33901

Merged
Cooper Cox (coopercox-ms) merged 25 commits into
Azure:devfrom
william051200:ocr
Aug 20, 2026
Merged

{Compute} az capacity reservation/az capacity reservation group/az vm: Support Open Capacity Reservation#33901
Cooper Cox (coopercox-ms) merged 25 commits into
Azure:devfrom
william051200:ocr

Conversation

@william051200

@william051200 William (william051200) commented Aug 17, 2026

Copy link
Copy Markdown
Member

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests
⚠️ None ️✔️ 130/130
⚠️AzureCLI-BreakingChangeTest
⚠️vm
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd capacity reservation group create cmd capacity reservation group create added parameter reservation_type
⚠️ 1006 - ParaAdd capacity reservation group update cmd capacity reservation group update added parameter reservation_type
⚠️ 1006 - ParaAdd vm create cmd vm create added parameter disable_capacity_reservation_assignment
⚠️ 1006 - ParaAdd vm update cmd vm update added parameter disable_capacity_reservation_assignment

Related command

az capacity reservation show
az capacity reservation group create/ update/ show/ list
az vm create/ update/ show/ list

Description

Resolve #33769

aaz Azure/aaz#1064

Testing Guide

Refer to azure-cli\src\azure-cli\azure\cli\command_modules\vm\tests\latest\test_vm_commands.py: test_open_capacity_reservation
This test case required canary access to run, which I dont have ATM. Requested for access, but still waiting.

History Notes

[Compute] az capacity reservation group create/update: Add new parameter --reservation-type to support Open Capacity Reservation
[Compute] az vm create/update: Add new parameter --disable-capacity-reservation-assignment to support Open Capacity Reservation


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

@william051200
William (william051200) requested a review from a team as a code owner August 17, 2026 02:08
Copilot AI lite review requested due to automatic review settings August 17, 2026 02:08
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi William (@william051200),
Since the current milestone time is less than 7 days, this pr may not catch up with this release.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds Azure CLI support for Open Capacity Reservation scenarios across the VM and Capacity Reservation command set, including wiring new properties through the VM create/update payload and exposing reservation type on capacity reservation group create.

Changes:

  • Add VM support for opting out of capacity reservation assignment via --disable-capacity-reservation-assignment/--no-capacity-reservation, and ensure the property round-trips through show/update flows.
  • Add --reservation-type for capacity reservation group create to enable Open (plus schema updates to show utilization details needed for Open reservations).
  • Refresh AAZ-generated schemas (notably to 2026-04-01) and add a new live-only scenario test for Open Capacity Reservation.

Reviewed changes

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

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py Adds a live-only end-to-end scenario validating Open Capacity Reservation behavior and utilization reporting.
src/azure-cli/azure/cli/command_modules/vm/operations/vm.py Extends snake_case conversion to include disableCapacityReservationAssignment.
src/azure-cli/azure/cli/command_modules/vm/custom.py Wires disable_capacity_reservation_assignment through VM create/update and exposes reservation_type in capacity reservation group wrappers.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/_wait.py Updates VM AAZ wait schema/api-version and includes new properties in the response model.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/_update.py Updates VM AAZ update schema/api-version and adds new modeled properties.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/_show.py Updates VM AAZ show schema/api-version and includes disableCapacityReservationAssignment in the model.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/_list.py Updates VM list schema/api-version and expands modeled fields.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/_list_all.py Updates VM list-all schema/api-version and expands modeled fields.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/_create.py Updates VM create schema/api-version and includes disableCapacityReservationAssignment modeling.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/capacity/reservation/group/_create.py Adds reservationType modeling for capacity reservation group creation and bumps api-version.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/capacity/reservation/group/_update.py Adds reservationType modeling for update and bumps api-version.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/capacity/reservation/group/_show.py Adds reservationType + utilization-related modeling and bumps api-version.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/capacity/reservation/group/_list.py Adds reservationType + utilization-related modeling and bumps api-version.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/capacity/reservation/_show.py Adds utilization details needed by the new Open reservation scenario and bumps api-version.
src/azure-cli/azure/cli/command_modules/vm/_template_builder.py Adds disableCapacityReservationAssignment to the ARM template payload and bumps VM apiVersion.
src/azure-cli/azure/cli/command_modules/vm/_params.py Adds CLI args for --disable-capacity-reservation-assignment/--no-capacity-reservation and --reservation-type.
src/azure-cli/azure/cli/command_modules/vm/_help.py Adds help examples for the new/updated capacity reservation and VM flags.
Suppressed comments (1)

src/azure-cli/azure/cli/command_modules/vm/_params.py:1607

  • --reservation-type is documented as immutable, but it’s currently registered in the general capacity reservation group argument context, which makes it available for capacity reservation group update as well. That implies users can change it after creation and can lead to service-side errors.

Move reservation_type so it’s only accepted on capacity reservation group create (and keep it out of update).

    with self.argument_context('capacity reservation group') as c:
        c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
        c.argument('capacity_reservation_group_name', options_list=['--capacity-reservation-group', '-n'],
                   help='The name of the capacity reservation group.')
        c.argument('tags', tags_type)
        c.argument('sharing_profile', nargs='*', help='Space-separated subscription resource IDs or nothing. Specify the settings to enable sharing across subscriptions for the capacity reservation group resource. Specify it to nothing to unsharing.')
        c.argument('reservation_type', arg_type=get_enum_type(ReservationType), help='The capacity reservation type. The reservation type cannot be changed after the capacity reservation group is created.')

    with self.argument_context('capacity reservation group create') as c:
        c.argument('zones', zones_type, help='Availability Zones to use for this capacity reservation group. If not provided, the group supports only regional resources in the region. If provided, enforces each capacity reservation in the group to be in one of the zones.')


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +2950 to +2951
- name: Update an open capacity reservation group.
text: az capacity reservation group update -n ReservationGroupName -g MyResourceGroup --reservation-type Open
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@azure-client-tools-agent

Copy link
Copy Markdown
Contributor

Live test results — azdev test --live --series (changed test files only)

FAIL (exit 1)

Selectors: test_vm_commands (module)
PR head ref: ocr
PR head sha: faceaa7c3aa72fbfc780bd4bea68016434c96047
PR base ref: dev
New test files in PR: false

Changed test files run
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/32242907779

Live-test recordings: 1 regenerated — archived in workflow artifact live-test-pr-33901 (recordings/).

ℹ️ This PR is from a fork, so recordings were not pushed automatically. Download them from the artifact and commit to your branch.

Recording files
src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_image_list_by_alias.yaml
Last 80 lines of azdev output

=============
| Run Tests |
=============


=====================
| Discovering Tests |
=====================

/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:13705: SyntaxWarning: invalid escape sequence '\]'
  self.cmd('vmss application set -g {rg} -n {vmss} --app-version-ids {vid1} {vid2} --enable-automatic-upgrade True\]', checks=[
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:18: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_compute': '\{"providers":\["Microsoft.Compute"\]\}',
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:19: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_empty': '\{"providers":\[\]\}'

test index updated: /home/runner/.azdev/env_config/home/runner/work/issue-sentinel/issue-sentinel/.venv/test_index/latest.json

Test on modules: test_vm_commands

WARNING: RUNNING TESTS LIVE
The tests are set to run against current profile "latest"
============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-9.1.1, pluggy-1.6.0 -- /home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli
plugins: forked-1.7.5, xdist-3.8.0
collecting ... collected 378 items

azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py::VMImageListByAliasesScenarioTest::test_vm_image_list_by_alias FAILED [  0%]

=================================== FAILURES ===================================
_________ VMImageListByAliasesScenarioTest.test_vm_image_list_by_alias _________
self = <latest.test_vm_commands.VMImageListByAliasesScenarioTest testMethod=test_vm_image_list_by_alias>

    def test_vm_image_list_by_alias(self):
        result = self.cmd('vm image list --offer ubuntu').get_output_in_json()
        self.assertTrue(len(result) >= 1)
        self.assertEqual(result[-1]['publisher'], 'Canonical')
>       self.assertTrue('lts' in result[-1]['sku'])
E       AssertionError: False is not true

azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:58: AssertionError
------------------------------ Captured log call -------------------------------
WARNING  cli.azure.cli.command_modules.vm.custom:custom.py:2736 You are viewing an offline list of images, use --all to retrieve an up-to-date list
- generated xml file: /home/runner/work/issue-sentinel/issue-sentinel/test-output/results.xml -
=========================== short test summary info ============================
FAILED azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py::VMImageListByAliasesScenarioTest::test_vm_image_list_by_alias - self = <latest.test_vm_commands.VMImageListByAliasesScenarioTest testMethod=test_vm_image_list_by_alias>

    def test_vm_image_list_by_alias(self):
        result = self.cmd('vm image list --offer ubuntu').get_output_in_json()
        self.assertTrue(len(result) >= 1)
        self.assertEqual(result[-1]['publisher'], 'Canonical')
>       self.assertTrue('lts' in result[-1]['sku'])
E       AssertionError: False is not true

azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:58: AssertionError
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
============================== 1 failed in 4.59s ===============================

Posted by agent-assist live-test workflow.

@azure-client-tools-agent azure-client-tools-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated CI Summary

The current head commit (faceaa7) has failing checks:

Please investigate the failing test instances above (Python 3.12 and 3.14 automation full-test runs) and push a fix. CI will re-run automatically on the next push.

@azure-client-tools-agent azure-client-tools-agent Bot added azure-client-tools-agent Pull request reviewed by Azure Client Tools Agent and removed Azure Client Tools Agent Requested Request Azure Client Tools Agent testing and review labels Aug 19, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

🔔 Routing this PR to @Azure/act-observability-squad.

@william051200

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@azure-client-tools-agent

Copy link
Copy Markdown
Contributor

Automated sensitive-information remediation ran on this pull request.

  • Detected categories: email address
  • Replaced with typed [REDACTED:category] placeholders in: PR description
  • Comment/review owners notified because Agent Assist cannot edit another user's text: none

Agent Assist does not modify source files. The PR creator must remove or replace each suspected value at the linked line:

  • No changed-file findings

If a credential was exposed, rotate or revoke it immediately. Detected values are never copied into this comment.

✅ Confirm the finding · ❌ Dispute the finding

GitHub only supports a fixed reaction set, so 👍 represents ✅ and 👎 represents ❌. The bot-created reactions are only poll choices.

@william051200

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@william051200

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@william051200

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@yanzhudd Julie Zhu (yanzhudd) changed the title [Compute] az capacity reservation/ az capacity reservation group/ az vm: Support Open Capacity Reservation [Compute] az capacity reservation/az capacity reservation group/az vm: Support Open Capacity Reservation Aug 20, 2026
@yanzhudd Julie Zhu (yanzhudd) changed the title [Compute] az capacity reservation/az capacity reservation group/az vm: Support Open Capacity Reservation {Compute} az capacity reservation/az capacity reservation group/az vm: Support Open Capacity Reservation Aug 20, 2026
@william051200

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@coopercox-ms
Cooper Cox (coopercox-ms) merged commit 9a778cc into Azure:dev Aug 20, 2026
50 checks passed
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 azure-client-tools-agent Pull request reviewed by Azure Client Tools Agent Compute az vm/vmss/image/disk/snapshot Reservations az reservations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compute] Add Open Capacity Reservation (OCR) support

7 participants