Overview
Scaling lets you adjust the compute capacity of your Azure Virtual Machine (VM) workloads to match demand. Azure supports two primary scaling models:
- Scale‑out (horizontal): Add or remove VM instances in a Virtual Machine Scale Set (VMSS).
- Scale‑up (vertical): Change the size (CPU, memory) of an individual VM.
This guide covers manual scaling, autoscaling with Azure Monitor, and best‑practice recommendations.
Prerequisites
- Azure subscription with Owner or Contributor rights.
- Azure CLI 2.53+ or Azure PowerShell 12.0+ installed.
- A VM or VM Scale Set already provisioned.
- Azure Monitor enabled for autoscaling.
Scale‑out with Virtual Machine Scale Sets
Manual scaling via Azure Portal
- Navigate to Virtual Machine Scale Sets in the Azure portal.
- Select your scale set → Scaling → Instance count.
- Enter the desired instance count and click Save.
Scale‑out using Azure CLI
Azure CLI
PowerShell
az vmss scale \
--resource-group MyResourceGroup \
--name MyScaleSet \
--new-capacity 5
Resize-AzVmss `
-ResourceGroupName "MyResourceGroup" `
-VMScaleSetName "MyScaleSet" `
-SkuCapacity 5
Autoscaling with Azure Monitor
Define autoscale rules based on metrics such as CPU percentage or queue length.
- Open the scale set → Scaling → Autoscale.
- Create a new Autoscale Profile.
- Add a rule, for example: When CPU > 70% for 5 minutes, increase instance count by 1.
- Save the profile.
Scale‑up (Resize) a Virtual Machine
Portal method
- Go to Virtual Machines → select your VM.
- Click Size under Settings.
- Choose the new size and click Resize.
Resize with Azure CLI
az vm resize \
--resource-group MyResourceGroup \
--name MyVM \
--size Standard_D4s_v3
Resize with PowerShell
Update-AzVM `
-ResourceGroupName "MyResourceGroup" `
-Name "MyVM" `
-Size "Standard_D4s_v3"
Best Practices
- Use VM Scale Sets for stateless workloads that can handle horizontal scaling.
- Leverage Autoscale to reduce costs during idle periods.
- Prefer Scale‑out over Scale‑up for higher availability.
- Set upper and lower bounds on instance counts to prevent runaway scaling.
- Monitor scaling actions with Azure Monitor logs and alerts.
FAQ
- Can I mix scale‑out and scale‑up?
- Yes. You can run a VMSS (scale‑out) and periodically resize individual VMs (scale‑up) based on workload needs.
- How long does a resize operation take?
- Typically 2‑5 minutes, depending on the VM size and underlying hardware.
- Will scaling affect my IP address?
- Scale‑out adds new instances with their own IPs. Scale‑up retains the original VM's IP unless you recreate the VM.