Microsoft Docs

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

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

MetricScale RuleAction
CPU PercentageGreater than 70% for 5 minutesIncrease instance count by 1
CPU PercentageLess than 30% for 10 minutesDecrease instance count by 1
Queue LengthGreater than 1000 for 2 minutesIncrease 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.