Mini Azure Project – Linux VM Scale Set with CPU-based Autoscaling (Azure CLI)
This mini-lab demonstrates how to deploy and operate an Azure Virtual Machine Scale Set (VMSS) using Azure CLI only, including CPU-based autoscaling (scale-out & scale-in). The project is part of my AZ-104 learning path and focuses on compute scalability, availability, and automation, without using the Azure Portal for deployment.
- Create a Resource Group
- Deploy a Linux VM Scale Set (Uniform) via Azure CLI
- Configure CPU-based autoscaling
- Trigger Scale-Out and Scale-In events
- Observe VMSS behavior in a real scenario
- Azure Subscription
- Azure CLI or Azure Cloud Shell
- Existing SSH key (~/.ssh/id_rsa.pub)
- Basic understanding of:
- Virtual Machines
- Load Balancers
- Metrics & autoscaling concepts
az group create \
--name rg-vmss-autoscale \
--location westeurope \
--output tableaz vmss create \
--resource-group rg-vmss-autoscale \
--name vmss-linux-autoscale \
--image Ubuntu2204 \
--vm-sku Standard_B2s \
--instance-count 1 \
--authentication-type ssh \
--admin-username "enteryouruserhere" \
--ssh-key-values ~/.ssh/id_rsa.pub \
--orchestration-mode Uniform \
--upgrade-policy-mode automatic \
--output table- VMSS created with 1 instance
- Standard Load Balancer, VNet, Subnet and NSG are created automatically
Proof - VM Scale Set created
Create Autoscale Profile
az monitor autoscale create \
--resource-group rg-vmss-autoscale \
--resource vmss-linux-autoscale \
--resource-type Microsoft.Compute/virtualMachineScaleSets \
--name autoscale-vmss-cpu \
--min-count 1 \
--max-count 3 \
--count 1Scale-Out Rule (CPU > 70%)
az monitor autoscale rule create \
--resource-group rg-vmss-autoscale \
--autoscale-name autoscale-vmss-cpu \
--condition "Percentage CPU > 70 avg 5m" \
--scale out 1Scale-In Rule (CPU < 50%)
az monitor autoscale rule create \
--resource-group rg-vmss-autoscale \
--autoscale-name autoscale-vmss-cpu \
--condition "Percentage CPU < 50 avg 10m" \
--scale in 1List VMMS Instances
az vmss list-instances \
--resource-group rg-vmss-autoscale \
--name vmss-linux-autoscale \
--query "[].instanceId" \
--output table- Initial state: 1 instance
- Under load: scaled out to 2 and 3 instances
- After load stopped: scaled back down to 2, then 1
- Scale-In takes longer due to averaging windows and cooldown behavior.
Proof - Scale-Out and Scale-in
Initial State:
Scale-Out (CPU > 70%):
Scale-In (CPU < 50%):
az group delete \
--name rg-vmss-autoscale \
--yes --no-wait- VM Scale Sets provide horizontal scalability for virtual machines
- Autoscale decisions are not instant – scale-in is intentionally slower than scale-out
- Autoscaling is driven by:
- Metric thresholds
- Averaging windows
- Cooldown periods
- VMSS abstracts:
- Load Balancer integration
- Instance lifecycle management
- CLI-only deployments expose real operational details often hidden in the Portal
- VMSS is a foundation service used before higher-level services like App Services or containers
This project focuses on infrastructure-level scaling, not application deployment
VMSS is commonly used as a building block for:
- High-availability compute
- Backend services
- Autoscaled workloads