You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Azure Virtual Machine Scale Sets (VMSS) let you create and manage a group of identical, load-balanced VMs. They automatically increase or decrease the number of VM instances in response to demand or a defined schedule, providing high availability and application resiliency.
A VMSS is a collection of VMs that are:
| Benefit | Description |
|---|---|
| Automatic scaling | Scale from 0 to 1,000 instances based on metrics or schedules |
| High availability | Distribute across fault domains and Availability Zones |
| Consistency | All VMs are identical — same image, size, and configuration |
| Integration | Works with Azure Load Balancer and Application Gateway |
| Cost efficiency | Scale in during low demand to reduce costs |
VMSS supports two orchestration modes:
# Create a Flexible VMSS
az vmss create \
--resource-group rg-vmss-demo \
--name myScaleSet \
--orchestration-mode Flexible \
--image Ubuntu2204 \
--vm-sku Standard_D2s_v5 \
--instance-count 3 \
--zones 1 2 3 \
--admin-username azureuser \
--generate-ssh-keys \
--lb myLoadBalancer
Autoscaling is the core capability of VMSS. It adjusts the number of instances to match demand.
Scale based on performance metrics:
| Metric | Scale Out When | Scale In When |
|---|---|---|
| CPU utilisation | Average > 70% for 5 minutes | Average < 30% for 10 minutes |
| Memory utilisation | Average > 80% for 5 minutes | Average < 40% for 10 minutes |
| Network In/Out | Bytes exceed threshold | Bytes below threshold |
| Disk Queue Length | Queue consistently growing | Queue consistently empty |
| Custom metrics | Application-specific thresholds | Application-specific thresholds |
Scale based on known patterns:
| Schedule | Instance Count |
|---|---|
| Weekdays 8:00–18:00 | 10 instances |
| Weekdays 18:00–8:00 | 3 instances |
| Weekends | 2 instances |
# Create an autoscale profile
az monitor autoscale create \
--resource-group rg-vmss-demo \
--resource myScaleSet \
--resource-type Microsoft.Compute/virtualMachineScaleSets \
--name autoscale-profile \
--min-count 2 \
--max-count 20 \
--count 3
# Add a scale-out rule (CPU > 70%)
az monitor autoscale rule create \
--resource-group rg-vmss-demo \
--autoscale-name autoscale-profile \
--condition "Percentage CPU > 70 avg 5m" \
--scale out 2
# Add a scale-in rule (CPU < 30%)
az monitor autoscale rule create \
--resource-group rg-vmss-demo \
--autoscale-name autoscale-profile \
--condition "Percentage CPU < 30 avg 10m" \
--scale in 1
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.