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, then create reservations. Once successfully created, reservations are immediately available for use with virtual machines. The capacity is reserved for your use as long as the reservation isn't deleted.

A well-formed request for Capacity Reservation group should always succeed as 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.

A Capacity Reservation creation succeeds or fails in its entirety. For a request to reserve 10 instances, success is returned only if all 10 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, single VMs can be done in stages. Create a capacity reservation with a smaller quantity and reallocate that quantity of virtual machines. This frees up quota to increase the quantity reserved and add more virtual machines. 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 until 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 using reserved capacity. If the Scale Set is updated 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 given VM size. For example, only one Capacity Reservation can be created for the VM size Standard_D2s_v3. Attempt to create a second reservation for Standard_D2s_v3 in the same Capacity Reservation group results in an error. However, another reservation can be created in the same group for other VM sizes, such as Standard_D4s_v3, Standard_D8s_v3, and so on.
  • 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 in Zone 1, another Capacity Reservation for Standard_D2s_v3 in Zone 2, and a third Capacity Reservation for Standard_D2s_v3 in Zone 3 is supported.

Checking VM sizes available for Capacity Reservation in a region

Before creating capacity reservation, VM sizes available for reservation can be checked for a particular region.

  1. Open Azure portal
  2. In the search bar, type Capacity Reservation groups
  3. Select Capacity Reservation groups from the options
  4. Select Create
  5. Under the Basics tab, create a Capacity Reservation group:
    1. Select a Subscription
    2. Select or create a Resource group
    3. Name your group
    4. Select a Region
    5. Optionally select Availability zones or opt not to specify any zones and allow Azure to choose for you
  6. Select Next
  7. On VM size, click on See all sizes to check what VM sizes are available for Capacity Reservation

Create a Capacity Reservation

  1. Create a Capacity Reservation group

    To create a Capacity Reservation group, construct the following PUT request on Microsoft.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"] 
    } 
    
  2. Create a Capacity Reservation

    To create a reservation, construct the following PUT request on Microsoft.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 above request creates a reservation in the East US location for five quantities of the D2s_v3 VM size.

Check on your Capacity Reservation

Once successfully created, the Capacity Reservation is 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" 
    } 
} 

Next steps