Azure Virtual Machine Scale Sets
Virtual Machine Scale Sets (VMSS) let you create and manage a group of identical, load‑balanced VMs. Scale sets provide high availability, auto‑scaling, and integrated health monitoring.
Key Features
- Automatic scaling based on metrics or schedules.
- Integration with Azure Load Balancer and Application Gateway.
- Support for Windows and Linux images.
- Custom VM extensions and scripts.
- Rolling upgrades with health checks.
Getting Started
Use the Azure portal, Azure CLI, or ARM templates to create a scale set.
Azure CLI Example
az vmss create \
--resource-group MyResourceGroup \
--name MyScaleSet \
--image UbuntuLTS \
--upgrade-policy-mode automatic \
--admin-username azureuser \
--generate-ssh-keys \
--instance-count 2 \
--vm-sku Standard_DS2_v2
ARM Template Snippet
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Compute/virtualMachineScaleSets",
"apiVersion": "2022-08-01",
"name": "myScaleSet",
"location": "[resourceGroup().location]",
"properties": {
"upgradePolicy": { "mode": "Automatic" },
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18.04-LTS",
"version": "latest"
}
},
"osProfile": {
"computerNamePrefix": "vmss",
"adminUsername": "azureuser",
"linuxConfiguration": { "disablePasswordAuthentication": true }
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "nicConfig",
"properties": {
"primary": true,
"ipConfigurations": [
{
"name": "ipConfig",
"properties": {
"subnet": { "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', 'myVnet', 'default')]" }
}
}
]
}
}
]
}
},
"sku": {
"name": "Standard_DS2_v2",
"capacity": 2,
"tier": "Standard"
}
}
}
]
}
Scaling Configuration
| Metric | Scale Rule | Action |
|---|---|---|
| CPU Percentage | Greater than 70% for 5 minutes | Increase instance count by 1 |
| CPU Percentage | Less than 30% for 10 minutes | Decrease instance count by 1 |
| Queue Length | Greater than 1000 for 2 minutes | Increase by 2 instances |
Common Tasks
FAQs
Can I mix VM sizes in a single scale set?
Yes. Use flexible orchestration mode and specify different VM sku values in the VM profile.
How are instances distributed across availability zones?
When zone‑aware deployment is enabled, instances are evenly spread across the zones you select.
What is the difference between manual and automatic upgrade modes?
Automatic upgrades apply new OS images automatically based on health checks. Manual upgrades require you to invoke the upgrade process.