Remove a Virtual Machine Scale Set association from a Capacity Reservation group
Applies to: ✔️ Uniform scale set ✔️ Flexible scale sets
This article walks you through removing a Virtual Machine Scale Set association from 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 Scale Set, change the Capacity Reservation group property at the scale set level, and then update the underlying VMs
- Option 2: Update the reserved quantity to zero and then change the Capacity Reservation group property
Deallocate the Virtual Machine Scale Set
The first option is to deallocate the Virtual Machine Scale Set, change the Capacity Reservation group property at the scale set level, and then update the underlying VMs.
Go to upgrade policies for more information about automatic, rolling, and manual upgrades.
Deallocate the Virtual Machine Scale Set
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{VMScaleSetName}/deallocate?api-version=2021-04-01
Update the Virtual Machine Scale Set to remove association with the Capacity Reservation group
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{VMScaleSetName}/update?api-version=2021-04-01
In the request body, set the
capacityReservationGroup
property to null to remove the Virtual Machine Scale Set association to the group:{ "location": "eastus", "properties": { "virtualMachineProfile": { "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 scale set cannot 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.
Go to upgrade policies for more information about automatic, rolling, and manual upgrades.
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 Virtual Machine Scale Set to remove the association with the Capacity Reservation group
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{VMScaleSetName}/update?api-version=2021-04-01
In the request body, set the
capacityReservationGroup
property to null to remove the association:{ "location": "eastus", "properties": { "virtualMachineProfile": { "capacityReservation": { "capacityReservationGroup":{ "id":null } } } } }
Upgrade policies
- Automatic Upgrade – In this mode, the scale set VM instances are automatically dissociated from the Capacity Reservation group without any further action from you.
- Rolling Upgrade – In this mode, the scale set VM instances are dissociated from the Capacity Reservation group without any further action from you. However, they are updated in batches with an optional pause time between them.
- Manual Upgrade – In this mode, nothing happens to the scale set VM instances when the Virtual Machine Scale Set is updated. You will need to individually remove each scale set VM by upgrading it with the latest Scale Set model.