Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: ✔️ Windows Virtual Machines ✔️ Linux Virtual Machines
You can use capacity reservation groups with new or existing virtual machines (VMs). To learn more about capacity reservations, see the Capacity reservation overview.
Associate a new virtual machine
To associate a new virtual machine to the capacity reservation group, the group must be explicitly referenced as a property of the VM. This reference protects the matching reservation in the group for applications and workloads intended to use it.
To add the capacityReservationGroup property to a VM, construct the following PUT request to the Microsoft.Compute provider:
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{VirtualMachineName}?api-version=2021-04-01
In the request body, include the capacityReservationGroup property:
{
"location": "eastus",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_D2s_v3"
},
…
"capacityReservation":{
"capacityReservationGroup":{
"id":"subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/CapacityReservationGroups/{CapacityReservationGroupName}"
}
"storageProfile": {
…
},
"osProfile": {
…
},
"networkProfile": {
…
}
}
}
Associate an existing virtual machine
Existing zonal virtual machines can simply be updated with Capacity Reservation Group property without the need of deallocation and it will automatically consume the capacity reservation. Existing regional virtual machines must be reallocated.
Regional Virtual Machine
For the initial release of a capacity reservation, a virtual machine must be allocated to a capacity reservation:
- Follow guidance to create a capacity reservation group and capacity reservation, if necessary. Or increment the quantity of an existing capacity reservation so there's unused reserved capacity.
- Deallocate the virtual machine.
- Update the capacity reservation group property on the VM.
- Restart the VM.
Follow the steps to associate the virtual machine to a capacity reservation group.
Deallocate the virtual machine:
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourcegroupname}/providers/Microsoft.Compute/virtualMachines/{VirtualMachineName}/deallocate?api-version=2021-04-01Add the
capacityReservationGroupproperty to the VM. Construct the followingPUTrequest toMicrosoft.Computeprovider:PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{VirtualMachineName}?api-version=2021-04-01In the request body, include the
capacityReservationGroupproperty:{ "location": "eastus", "properties": { "capacityReservation": { "capacityReservationGroup": { "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}" } } } }
Zonal Virtual Machine
A zonal virtual machine can be allocated to a capacity reservation without the need of reallocation. If you have capacity in an existing capacity reservation group, you can add an existing zonal virtual machine to the capacity reservation group and update the VM to use a matching capacity reservation in the capacity reservation group.
Important
The feature to associate an existing zonal VM to a Capacity Reservation Group without the need to deallocate, is currently in Preview. See the Preview Terms of Use for legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability.
- Follow guidance to create a capacity reservation group and capacity reservation, if necessary. Or increment the quantity of an existing capacity reservation so there's unused reserved capacity.
- Update the capacity reservation group property on the VM.
Follow the steps to associate the virtual machine to a capacity reservation group.
Add the capacityReservationGroup property to the VM. Construct the following PUT request to Microsoft.Compute provider:
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{VirtualMachineName}?api-version=2021-04-01
In the request body, include the capacityReservationGroup property:
{
"location": "eastus",
"properties": {
"capacityReservation": {
"capacityReservationGroup": {
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}"
}
}
}
}
Secure existing zonal virtual machine using zero size reservation
Zonally deployed virtual machines can be converted to using an On Demand Capacity Reservation without reallocation. If you do not have capacity in an existing capacity reservation group, you can start by creating a zero size matching reservation to secure your workloads. The basic process involves 3 steps:
Create a Capacity Reservation Group and then matching capacity reservations in each target zone with the reserved quantity set to zero. This requires no additional quota or capacity. For more information on how to create a reservation, see Create a capacity reservation.
Associate existing running zonal virtual machine to the capacity reservation. Set the Virtual Machine capacityReservationGroup property to the desired Capacity Reservation Group. When complete, each target capacity reservation will be overallocated. See Zonal Virtual Machine.
Increase the reserved quantity of each capacity reservation (CR) to match the allocated Virtual Machine (VM) count. Since each CR is already overallocated, this step requires no additional quota or capacity. For more information on how to update the reserved count, see Capacity reservation modify.
After the quantity increase, you should see the CR in a fully allocated state with all the virtual machines allocated. See View VM allocation with the Instance View.
For information on using shared capacity reservation group, see Secure existing zonal workloads using zero size reservation in Shared capacity Reservation Group.
View VM allocation with the Instance View
After the capacityReservationGroup property is set, an association now exists between the VM and the group. Azure automatically finds the matching capacity reservation in the group and consumes a reserved slot. The capacity reservation's Instance View reflects the new VM in the virtualMachinesAllocated property:
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/CapacityReservationGroups/{capacityReservationGroupName}?$expand=instanceView&api-version=2021-04-01
{
"name":"{CapacityReservationGroupName}",
"id":"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{CapacityReservationGroupName}",
"type":"Microsoft.Compute/capacityReservationGroups",
"location":"eastus",
"properties":{
"capacityReservations":[
{
"id":"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/ {CapacityReservationGroupName}/capacityReservations/{CapacityReservationName}"
}
],
"virtualMachinesAssociated":[
{
"id":"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{myVM}"
}
],
"instanceView":{
"capacityReservations":[
{
"name":"{CapacityReservationName}",
"utilizationInfo":{
"virtualMachinesAllocated":[
{
"id":"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{myVM}"
}
]
},
"statuses":[
{
"code":"ProvisioningState/succeeded",
"level":"Info",
"displayStatus":"Provisioning succeeded",
"time":"2021-05-25T15:12:10.4165243+00:00"
}
]
}
]
}
}
}