How to Fix: Azure VM AllocationFailed

Framework: AzureError Code: AllocationFailedSeverity: High

Symptoms

Root Cause

Azure does not guarantee capacity for all VM sizes in all regions at all times. The AllocationFailed error occurs when the Azure region or availability zone lacks sufficient physical compute resources (CPU, memory, GPU) to fulfill the VM request at that moment. This is a transient capacity constraint, not a configuration or quota issue.

Resolution (Step-by-Step)

  1. Retry the deployment immediately. Capacity can free up quickly.

    az vm create --resource-group <rg> --name <vm> --image Ubuntu2204 --admin-username azureuser --generate-ssh-keys
  2. Deploy to a different availability zone within the same region.

    az vm create --resource-group <rg> --name <vm> --image Ubuntu2204 --zone 2 --admin-username azureuser --generate-ssh-keys
  3. Try a different VM size in the same family (e.g., Standard_D2s_v3 instead of Standard_D2_v3) or a different family (e.g., Standard_B2s).

    az vm create --resource-group <rg> --name <vm> --image Ubuntu2204 --size Standard_D2s_v3 --admin-username azureuser --generate-ssh-keys
  4. Deploy to a different region with available capacity.

    az vm create --resource-group <rg> --name <vm> --image Ubuntu2204 --location eastus2 --admin-username azureuser --generate-ssh-keys
  5. Use an Azure Reserved VM Instance or Capacity Reservation to guarantee capacity for future deployments.

    az capacity reservation group create --resource-group <rg> --name <reservation-group> --location eastus
    az capacity reservation create --resource-group <rg> --capacity-reservation-group <reservation-group> --name <reservation> --sku Standard_D2s_v3 --capacity 1
  6. Deploy using an Azure Resource Manager (ARM) template with availabilityZones or platformFaultDomain settings to spread across fault domains.

Verification

Confirm the VM is running and healthy:

az vm show --resource-group <rg> --name <vm> --query "provisioningState" -o tsv

Expected output: Succeeded