Create a capacity reservation
Applies to: ✔️ Linux VMs ✔️ Windows VMs ✔️ Uniform scale set ✔️ Flexible scale sets
Capacity reservation is always created as part of a capacity reservation group. The first step is to create a group if a suitable one doesn't exist already, and then create reservations. After reservations are successfully created, they're immediately available for use with virtual machines (VMs). The capacity is reserved for your use as long as the reservation isn't deleted.
A well-formed request for a capacity reservation group should always succeed because it doesn't reserve any capacity. It just acts as a container for reservations. However, a request for capacity reservation could fail if you don't have the required quota for the VM series or if Azure doesn't have enough capacity to fulfill the request. Either request more quota or try a different VM size, location, or zone combination.
Capacity reservation creation succeeds or fails in its entirety. For a request to reserve 10 instances, success is returned only if all 10 instances could be allocated. Otherwise, the capacity reservation creation fails.
Considerations
The capacity reservation must meet the following rules:
- The location parameter must match the location property for the parent capacity reservation group. A mismatch results in an error.
- The VM size must be available in the target region. Otherwise, the reservation creation fails.
- The subscription must have available quota equal to or more than the quantity of VMs being reserved for the VM series and for the region overall. If needed, request more quota.
- As needed to satisfy existing quota limits, you can do single VMs in stages. Create a capacity reservation with a smaller quantity and reallocate that quantity of VMs. This approach frees up quota to increase the quantity reserved and add more VMs. Alternatively, if the subscription uses different VM sizes in the same series, reserve and redeploy VMs for the first size. Then add a reservation to the group for another size and redeploy the VMs for the new size to the reservation group. Repeat the process until it's complete.
- For scale sets, available quota is required unless the scale set or you delete its VM instances, capacity is reserved, and the scale set instances are added by using reserved capacity. If the scale set is updated by using blue green deployment, then reserve the capacity and deploy the new scale set to the reserved capacity at the next update.
- Each capacity reservation group can have exactly one reservation for a specific VM size. For example, you can create only one capacity reservation for the VM size
Standard_D2s_v3
. Attempting to create a second reservation forStandard_D2s_v3
in the same capacity reservation group results in an error. However, you can create another reservation in the same group for other VM sizes, such asStandard_D4s_v3
andStandard_D8s_v3
. - For a capacity reservation group that supports zones, each reservation type is defined by the combination of VM size and zone. For example, one capacity reservation for
Standard_D2s_v3
inZone 1
, another capacity reservation forStandard_D2s_v3
inZone 2
, and a third capacity reservation forStandard_D2s_v3
inZone 3
are supported.
Check VM sizes that are available for capacity reservation in a region
Before you create a capacity reservation, you can check the VM sizes that are available for the reservation for a particular region.
- Open the Azure portal.
- In the search bar, enter capacity reservation groups.
- Select Capacity reservation groups from the options.
- Select Create.
- On the Basics tab, create a capacity reservation group:
- Select a Subscription.
- Select or create a resource group.
- Name your group.
- Select a region.
- Optionally, select Availability zones or allow Azure to choose for you.
- Select Next.
- On VM size, select See all sizes to check what VM sizes are available for capacity reservation.
Create a capacity reservation
Create a capacity reservation group.
To create a capacity reservation group, construct the following
PUT
request on theMicrosoft.Compute
provider:PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/CapacityReservationGroups/{CapacityReservationGroupName}&api-version=2021-04-01
In the request body, include the following parameter:
{ "location":"eastus" }
This group is created to contain reservations for the US East location.
The group in the following example only supports regional reservations because zones weren't specified at the time of creation. To create a zonal group, pass an extra parameter
zone
in the request body:{ "location":"eastus", "zones": ["1", "2", "3"] }
Create a capacity reservation.
To create a reservation, construct the following
PUT
request on theMicrosoft.Compute
provider: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:
{ "location": "eastus", "sku": { "name": "Standard_D2s_v3", "capacity": 5 }, "tags": { "environment": "testing" }
The preceding request creates a reservation in the East US location for five quantities of the D2s_v3 VM size.
Check on your capacity reservation
After the capacity reservation is successfully created, it's immediately available for use with VMs.
GET
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/CapacityReservationGroups/{CapacityReservationGroupName}/capacityReservations/{capacityReservationName}?api-version=2021-04-01
{
"name": "<CapacityReservationName>",
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{CapacityReservationGroupName}/capacityReservations/{CapacityReservationName}",
"type": "Microsoft.Compute/capacityReservationGroups/capacityReservations",
"location": "eastus",
"tags": {
"environment": "testing"
},
"sku": {
"name": "Standard_D2s_v3",
"capacity": 5
},
"properties": {
"reservationId": "<reservationId>",
"provisioningTime": "<provisioningTime>",
"provisioningState": "Updating"
}
}