Remove a VM association from a Capacity Reservation group
This article walks you through the steps of removing a VM association to a Capacity Reservation group. To learn more about capacity reservations, see the overview article.
Because both the VM and the underlying Capacity Reservation logically occupy capacity, Azure imposes some constraints on this process to avoid ambiguous allocation states and unexpected errors.
There are two ways to change an association:
- Option 1: Deallocate the virtual machine, change the Capacity Reservation group property, and optionally restart the virtual machine
- Option 2: Update the reserved quantity to zero and then change the Capacity Reservation group property
Deallocate the VM
The first option is to deallocate the VM, change the Capacity Reservation group property, and optionally restart the VM.
Deallocate the VM
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{virtualMachineName}/deallocate?api-version=2021-04-01
Update the VM to remove association with the Capacity Reservation group
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{virtualMachineName}/update?api-version=2021-04-01
In the request body, set the
capacityReservationGroup
property to null to remove the VM association to the group:{ "location": "eastus", "properties": { "capacityReservation": { "capacityReservationGroup": { "id":null } } } }
Update the reserved quantity to zero
The second option involves updating the reserved quantity to zero and then changing the Capacity Reservation group property.
This option works well when the virtual machine can’t be deallocated and when a reservation is no longer needed. For example, you may create a Capacity Reservation to temporarily assure capacity during a large-scale deployment. Once completed, the reservation is no longer needed.
Update the reserved quantity to zero
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/CapacityReservationGroups/{CapacityReservationGroupName}/CapacityReservations/{CapacityReservationName}?api-version=2021-04-01
In the request body, include the following parameters:
{ "sku": { "capacity": 0 } }
Note that
capacity
property is set to 0.Update the VM to remove the association with the Capacity Reservation group
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{VirtualMachineName}/update?api-version=2021-04-01
In the request body, set the
capacityReservationGroup
property to null to remove the association:{ "location": "eastus", "properties": { "capacityReservation": { "capacityReservationGroup": { "id":null } } } }
Next steps
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for