Skip to content

Commit b54aa8c

Browse files
Merge pull request #2665 from MicrosoftDocs/main
Auto Publish – main to live - 2025-11-24 23:00 UTC
2 parents e36cb2e + d432f88 commit b54aa8c

File tree

4 files changed

+204
-89
lines changed

4 files changed

+204
-89
lines changed

articles/virtual-machines/capacity-reservation-associate-virtual-machine-scale-set.md

Lines changed: 84 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -544,21 +544,25 @@ To associate a Virtual Machine Scale Set with a Capacity Reservation Group, see
544544

545545
## Associate an existing virtual machine scale set to a capacity reservation group
546546

547-
To add an existing capacity reservation group to an existing uniform scale set:
547+
Existing zonal virtual machine scale set can simply be updated with Capacity Reservation Group property without the need of deallocation. Existing regional virtual machine scale set can include similar process but must be reallocated.
548+
549+
### Regional Virtual Machine Scale Set
550+
551+
To add an existing regional capacity reservation group to an existing uniform scale set:
548552

549553
- Stop the scale set to deallocate the VM instances.
550554
- Update the scale set to use a matching capacity reservation group.
551555
- Start the scale set.
552556

553557
This process ensures that the placement for the capacity reservations and scale set in the region are compatible.
554558

555-
### Important notes on upgrade policies
559+
#### Important notes on upgrade policies
556560

557561
- **Automatic upgrade**: In this mode, the scale set VM instances are automatically associated to the capacity reservation group without any further action from you. When the scale set VMs are reallocated, they start consuming the reserved capacity.
558562
- **Rolling upgrade**: In this mode, scale set VM instances are associated to the capacity reservation group without any further action from you. However, they're updated in batches with an optional pause time between them. When the scale set VMs are reallocated, they start consuming the reserved capacity.
559563
- **Manual upgrade**: In this mode, nothing happens to the scale set VM instances when the virtual machine scale set is attached to a capacity reservation group. You need to update to each scale set VM by [upgrading it with the latest scale set model](../virtual-machine-scale-sets/virtual-machine-scale-sets-upgrade-policy.md).
560564

561-
### [API](#tab/api2)
565+
#### [API](#tab/api2)
562566

563567
1. Deallocate the virtual machine scale set:
564568

@@ -587,7 +591,7 @@ This process ensures that the placement for the capacity reservations and scale
587591
}
588592
```
589593
590-
### [CLI](#tab/cli2)
594+
#### [CLI](#tab/cli2)
591595
592596
1. Deallocate the virtual machine scale set:
593597
@@ -607,7 +611,7 @@ This process ensures that the placement for the capacity reservations and scale
607611
--capacity-reservation-group /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}
608612
```
609613
610-
### [PowerShell](#tab/powershell2)
614+
#### [PowerShell](#tab/powershell2)
611615
612616
1. Deallocate the virtual machine scale set:
613617
@@ -634,7 +638,7 @@ This process ensures that the placement for the capacity reservations and scale
634638
635639
To learn more, see the Azure PowerShell commands [Stop-AzVmss](/powershell/module/az.compute/stop-azvmss), [Get-AzVmss](/powershell/module/az.compute/get-azvmss), and [Update-AzVmss](/powershell/module/az.compute/update-azvmss).
636640
637-
### [Portal](#tab/portal2)
641+
#### [Portal](#tab/portal2)
638642
639643
<!-- no images necessary if steps are straightforward -->
640644
@@ -648,96 +652,100 @@ To learn more, see the Azure PowerShell commands [Stop-AzVmss](/powershell/modul
648652
---
649653
<!-- The three dashes above show that your section of tabbed content is complete. Don't remove them :) -->
650654
651-
## View virtual machine scale set association with the Instance View
655+
### Zonal Virtual Machine Scale Set
656+
657+
If you have capacity in an existing capacity reservation group and you want to add an existing zonal uniform scale set to it, simply update the scale set to the capacity reservation group to use a matching capacity reservation.
658+
659+
> [!IMPORTANT]
660+
> The feature to associate an existing zonal scale set to a reservation group without the need to deallocate, is currently in **Preview**. See the [Preview Terms of Use](https://azure.microsoft.com/support/legal/preview-supplemental-terms/) for legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability.
661+
> The feature is currently not available in Microsoft Azure Government and Microsoft Azure operated by 21Vianet.
662+
663+
#### Important notes on upgrade policies
664+
665+
- **Automatic upgrade**: In this mode, the scale set VM instances are automatically associated to the capacity reservation group without any further action from you. If already running, the scale set VM instances start consuming the reserved capacity. If the existing scale set VMs are in deallocated state, they start consuming the reserved capacity when reallocated.
666+
- **Rolling upgrade**: In this mode, scale set VM instances are associated to the capacity reservation group without any further action from you. However, they're updated in batches with an optional pause time between them. If already running, the scale set VM instances start consuming the reserved capacity. If the existing scale set VMs are in deallocated state, they start consuming the reserved capacity when reallocated.
667+
- **Manual upgrade**: In this mode, nothing happens to the scale set VM instances when the virtual machine scale set is attached to a capacity reservation group. You need to update to each scale set VM by [upgrading it with the latest scale set model](../virtual-machine-scale-sets/virtual-machine-scale-sets-upgrade-policy.md).
652668
653-
After the uniform virtual machine scale set is associated to the capacity reservation group, all the subsequent VM allocations will happen against the capacity reservation. Azure automatically finds the matching capacity reservation in the group and consumes a reserved slot.
669+
#### [API](#tab/api2)
654670
655-
### [API](#tab/api3)
656671
657-
The capacity reservation group Instance View reflects the new scale set VMs under the `virtualMachinesAssociated` and `virtualMachinesAllocated` properties:
672+
Add the `capacityReservationGroup` property to the scale set model. Construct the following `PUT` request to `Microsoft.Compute` provider:
658673
659674
```rest
660-
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/CapacityReservationGroups/{CapacityReservationGroupName}?$expand=instanceview&api-version=2021-04-01
675+
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourcegroupname}/providers/Microsoft.Compute/virtualMachineScaleSets/{VMScaleSetName}?api-version=2021-04-01
661676
```
662677

678+
In the request body, include the `capacityReservationGroup` property:
679+
663680
```json
664-
{
665-
    "name": "<CapacityReservationGroupName>",
666-
    "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{CapacityReservationGroupName}",
667-
    "type": "Microsoft.Compute/capacityReservationGroups",
668-
    "location": "eastus"
669-
},
670-
"properties": {
671-
        "capacityReservations": [
672-
            {
673-
                "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{CapacityReservationGroupName}/capacityReservations/{CapacityReservationName}"
674-
            }
675-
        ],
676-
        "virtualMachinesAssociated": [
677-
            {
678-
                "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{VMScaleSetName}/virtualMachines/{VirtualMachineId}"
679-
            }
680-
        ],
681-
        "instanceView": {
682-
            "capacityReservations": [
683-
                {
684-
                    "name": "<CapacityReservationName>",
685-
                    "utilizationInfo": {
686-
"virtualMachinesAllocated": [
687-
            {
688-
                "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{VMScaleSetName}/virtualMachines/{VirtualMachineId}"
689-
             }
690-
]
691-
},
692-
"statuses": [
693-
                        {
694-
                            "code": "ProvisioningState/succeeded",
695-
                            "level": "Info",
696-
                            "displayStatus": "Provisioning succeeded",
697-
                            "time": "2021-05-25T15:12:10.4165243+00:00"
698-
                        }
699-
                    ]
700-
                }
701-
            ]
702-
        }
703-
    }
704-
}
705-
```
706-
707-
### [CLI](#tab/cli3)
681+
"location": "eastus",
682+
"properties": {
683+
"virtualMachineProfile": {
684+
"capacityReservation": {
685+
"capacityReservationGroup": {
686+
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}"
687+
}
688+
}
689+
}
690+
}
691+
```
708692

709-
```azurecli-interactive
710-
az capacity reservation group show
711-
-g myResourceGroup
712-
-n myCapacityReservationGroup
713-
```
693+
#### [CLI](#tab/cli2)
714694

715-
### [PowerShell](#tab/powershell3)
695+
To associate the scale set to the capacity reservation group using the Azure CLI:
716696

717-
View the association of your virtual machine scale set and capacity reservation group by using Instance View in PowerShell.
697+
```azurecli-interactive
698+
az vmss update
699+
--resource-group myResourceGroup
700+
--name myVMSS
701+
--capacity-reservation-group /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}
702+
```
718703

719-
```powershell-interactive
720-
$CapRes=
721-
Get-AzCapacityReservationGroup
722-
-ResourceGroupName <"ResourceGroupName">
723-
-Name <"CapacityReservationGroupName">
724-
-InstanceView
704+
#### [PowerShell](#tab/powershell2)
725705

726-
$CapRes.InstanceView.Utilizationinfo.VirtualMachinesAllocated
727-
```
706+
To associate the scale set to the capacity reservation group using Azure PowerShell:
728707

729-
To learn more, see the Azure PowerShell command [Get-AzCapacityReservationGroup](/powershell/module/az.compute/get-azcapacityreservationGroup).
708+
```powershell-interactive
709+
$vmss =
710+
Get-AzVmss
711+
-ResourceGroupName "myResourceGroup"
712+
-VMScaleSetName "myVmss"
713+
714+
Update-AzVmss
715+
-ResourceGroupName "myResourceGroup"
716+
-VMScaleSetName "myVmss"
717+
-VirtualMachineScaleSet $vmss
718+
-CapacityReservationGroupId "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}"
719+
```
730720

731-
### [Portal](#tab/portal3)
721+
To learn more, see the Azure PowerShell commands [Stop-AzVmss](/powershell/module/az.compute/stop-azvmss), [Get-AzVmss](/powershell/module/az.compute/get-azvmss), and [Update-AzVmss](/powershell/module/az.compute/update-azvmss).
732722

733-
1. Open [Azure portal](https://portal.azure.com).
734-
1. Go to your capacity reservation group.
735-
1. Under **Setting**, select **Resources**.
736-
1. In the table, you can see all the scale set VMs that are associated to the capacity reservation group.
723+
#### [Portal](#tab/portal2)
724+
725+
To associate the scale set to the capacity reservation group using the Azure portal:
726+
727+
1. Open the [Azure portal](https://portal.azure.com).
728+
1. Go to your Virtual Machine Scale Set.
729+
1. Select **Overview**.
730+
1. Go to **Configurations** on the left.
731+
1. In the **Capacity Reservation group** dropdown list, select the group that you want to associate to the scale set.
737732

738733
---
739734
<!-- The three dashes above show that your section of tabbed content is complete. Don't remove them :) -->
740735

736+
737+
### Secure existing zonal virtual machine scale sets using zero size reservation
738+
739+
Zonally deployed virtual machines scale sets 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:
740+
741+
1. 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](/azure/virtual-machines/capacity-reservation-create?tabs=portal1%2Capi1%2Capi2#create-a-capacity-reservation-1).
742+
743+
2. Associate existing running zonal virtual machine scale set to the capacity reservation. Set the Virtual Machine Scale Set (VMSS) capacityReservationGroup property to the desired Capacity Reservation Group, then execute a model update on the VMSS (VMSS uniform) or update each member VM with the capacityReservationGroup property (VMSS Flex). When complete, each target capacity reservation will be overallocated See [Zonal Virtual Machine Scale Set](#zonal-virtual-machine-scale-set)
744+
745+
3. 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](/azure/virtual-machines/capacity-reservation-modify?tabs=api1%2Capi2%2Capi3#update-the-number-of-instances-reserved)
746+
747+
After the quantity increase, you should see the CR in a fully allocated state with all the VMSS virtual machines allocated. See [View VM allocation with the Instance View](/azure/virtual-machines/capacity-reservation-associate-vm?tabs=api1%2Capi2%2Capi3#view-vm-allocation-with-the-instance-view).
748+
741749
## Region and availability zone considerations
742750

743751
You can create virtual machine scale sets regionally or in one or more availability zones to help protect them from datacenter-level failure. To learn more about multizonal virtual machine scale sets, see [Virtual machine scale sets that use availability zones](../virtual-machine-scale-sets/virtual-machine-scale-sets-use-availability-zones.md).

0 commit comments

Comments
 (0)