Azure VM Availability and Scaling: Availability Zones, Availability Sets, VM Scale Sets, Autoscale and Images
Availability Options
| Option | Protects from | Notes |
|---|---|---|
| Single VM (premium disks) | Some hardware faults | Lowest SLA |
| Availability set | Rack failure and planned maintenance in one datacenter | Uses fault domains and update domains |
| Availability zones | Datacenter failure | VMs in zones 1, 2, 3. Higher SLA. Preferred where available |
| Scale set across zones | Datacenter failure plus load | Best for identical stateless VMs |
- Fault domain: group sharing power and network. Update domain: group rebooted together during maintenance
- A VM is either in an availability set or a zone design. Choose at creation time
bash
az vm availability-set create -g rg-vm -n avset-web --platform-fault-domain-count 2 --platform-update-domain-count 5
az vm create -g rg-vm -n web02 --availability-set avset-web --image Ubuntu2204 --admin-username azureuser --generate-ssh-keys
VM Scale Sets (VMSS)
- A group of identical VMs managed together with a load balancer
- Flexible orchestration is the recommended mode for new deployments
- Supports autoscale, zones, rolling upgrades and Spot instances
bash
az vmss create -g rg-vm -n vmss-web --image Ubuntu2204 --vm-sku Standard_B2s --instance-count 2 \
--zones 1 2 3 --admin-username azureuser --generate-ssh-keys --upgrade-policy-mode Automatic --lb lb-web
az vmss list-instances -g rg-vm -n vmss-web -o table
az vmss scale -g rg-vm -n vmss-web --new-capacity 4
Autoscale
| Type | Example |
|---|---|
| Metric-based | Add 2 instances when average CPU is above 70% for 10 minutes |
| Schedule-based | Run 6 instances on weekdays 9 to 18 |
| Predictive | Scale ahead based on a pattern (check availability) |
bash
az monitor autoscale create -g rg-vm --resource vmss-web --resource-type Microsoft.Compute/virtualMachineScaleSets \
--name auto-web --min-count 2 --max-count 10 --count 2
az monitor autoscale rule create -g rg-vm --autoscale-name auto-web --condition "Percentage CPU > 70 avg 10m" --scale out 2
az monitor autoscale rule create -g rg-vm --autoscale-name auto-web --condition "Percentage CPU < 30 avg 10m" --scale in 1
Scale-in rule Always add a scale-in rule and keep a gap between thresholds (for example 70 and 30) to avoid flapping.
Images
- Marketplace images are ready-made
- A custom image captures a configured VM (generalize it first:
sudo waagent -deprovision+useron Linux, Sysprep on Windows) - Store versioned images in Azure Compute Gallery and replicate them to other regions
- Azure Image Builder automates image creation in a pipeline
bash
az vm deallocate -g rg-vm -n web01
az vm generalize -g rg-vm -n web01
az image create -g rg-vm -n web-image --source web01
Practice
- Create a scale set across three zones
- Add autoscale rules and test with CPU load
- Create a custom image from a configured VM
- Explain fault domain versus update domain
Conclusion
Use zones or availability sets for resilience and scale sets with autoscale for elastic capacity. Build custom images in a gallery so every VM starts identical.
Quick Summary: availability options; VMSS; autoscale; images.

