AZURE

VMSSInstanceNotFound - VMSS Instance Not Found: Instance Does Not Exist

Hitting VMSSInstanceNotFound means ARM couldn't locate the scale set instance—wrong instance ID (usually numeric like 0, 1, 2), instance was deleted, or it's deallocated (stopped and deallocated). This 404 client-side error occurs when ARM validates instance IDs before operations. While specific to Virtual Machine Scale Sets, similar instance lookup failures happen in AKS node instances and App Service app service instances. Deallocated instances need to be started before most operations work. Scale sets may auto-create instances based on capacity settings.

#Common Causes

  • Invalid Instance ID Format: The instance ID is incorrect or doesn't match the expected format. Instance IDs are typically numeric (0, 1, 2, etc.) or follow a specific naming pattern depending on the scale set configuration. This is persistent—you must use the correct instance ID.
  • Deleted Instance: The instance has been deleted from the scale set. Deleted instances aren't accessible via standard queries. Scale sets may automatically create new instances based on capacity settings (min/max count). This is persistent—you must use a different instance or wait for the scale set to create new instances.
  • Deallocated Instance: Instances have been deallocated (stopped and deallocated) and may not be immediately accessible for operations. Deallocated instances need to be started before most operations. This can be transient—starting the instance and retrying may help.

Solutions

  1. 1Step 1: Diagnose - List all instances in the scale set to see available instance IDs: az vmss list-instances --resource-group <rg> --name <vmss> --query "[].{InstanceId:instanceId,Name:name,ProvisioningState:provisioningState}" --output table
  2. 2Step 2: Diagnose - Get specific instance details if you have the instance ID: az vmss get-instance-view --resource-group <rg> --name <vmss> --instance-id <id> --query "{InstanceId:instanceId,ProvisioningState:provisioningState,PowerState:statuses[?code=='PowerState/'].displayStatus}" --output table
  3. 3Step 3: Diagnose - Check instance status and power state: az vmss get-instance-view --resource-group <rg> --name <vmss> --instance-id <id> --query "statuses[].{Code:code,DisplayStatus:displayStatus}" --output table
  4. 4Step 4: Fix - If instance ID is wrong, use the correct instance ID from the list. Verify the instance ID format matches the scale set's naming pattern.
  5. 5Step 5: Fix - If instance was deleted, wait for the scale set to create new instances based on capacity settings, or manually scale up: az vmss scale --resource-group <rg> --name <vmss> --new-capacity <count>
  6. 6Step 6: Fix - If instance is deallocated, start it: az vmss start --resource-group <rg> --name <vmss> --instance-ids <id>
  7. 7Step 7: Verify - After finding the correct instance or starting a deallocated one, retry your operation. It should succeed instead of returning VMSSInstanceNotFound.

</>Code Examples

VM Scale Set Instance Lookup and Management
1# This script helps diagnose VMSSInstanceNotFound by finding and managing scale set instances
2
3# Step 1: Set scale set details (replace with your values)
4RESOURCE_GROUP="my-resource-group"
5VMSS_NAME="myVMSS"
6echo "Checking instances for VM scale set: ${VMSS_NAME}"
7
8# Step 2: List all instances in the scale set
9echo "Listing all instances in scale set..."
10az vmss list-instances \
11  --resource-group ${RESOURCE_GROUP} \
12  --name ${VMSS_NAME} \
13  --query "[].{InstanceId:instanceId,Name:name,ProvisioningState:provisioningState,ComputerName:osProfile.computerName}" \
14  --output table
15
16# Step 3: Get instance IDs
17INSTANCE_IDS=$(az vmss list-instances \
18  --resource-group ${RESOURCE_GROUP} \
19  --name ${VMSS_NAME} \
20  --query "[].instanceId" \
21  --output tsv)
22
23if [ ! -z "${INSTANCE_IDS}" ]; then
24  echo "Available instance IDs: ${INSTANCE_IDS}"
25else
26  echo "WARNING: No instances found in scale set"
27fi
28
29# Step 4: Example instance ID to check (replace with your instance ID)
30INSTANCE_ID="0"
31echo "Checking instance: ${INSTANCE_ID}"
32
33# Step 5: Get specific instance details
34echo "Getting instance details..."
35az vmss get-instance-view \
36  --resource-group ${RESOURCE_GROUP} \
37  --name ${VMSS_NAME} \
38  --instance-id ${INSTANCE_ID} \
39  --query "{InstanceId:instanceId,ProvisioningState:provisioningState,PowerState:statuses[?code=='PowerState/'].displayStatus,VMHealth:statuses[?code=='HealthState/'].displayStatus}" \
40  --output table
41
42# Step 6: Check instance status codes
43echo "Checking instance status codes..."
44az vmss get-instance-view \
45  --resource-group ${RESOURCE_GROUP} \
46  --name ${VMSS_NAME} \
47  --instance-id ${INSTANCE_ID} \
48  --query "statuses[].{Code:code,DisplayStatus:displayStatus,Time:time}" \
49  --output table
50
51# Step 7: Check scale set capacity settings
52echo "Checking scale set capacity settings..."
53az vmss show \
54  --resource-group ${RESOURCE_GROUP} \
55  --name ${VMSS_NAME} \
56  --query "{Capacity:sku.capacity,MinCapacity:sku.capacity,MaxCapacity:sku.capacity}" \
57  --output table
58
59# Step 8: Check if instance is deallocated and start if needed
60POWER_STATE=$(az vmss get-instance-view \
61  --resource-group ${RESOURCE_GROUP} \
62  --name ${VMSS_NAME} \
63  --instance-id ${INSTANCE_ID} \
64  --query "statuses[?code=='PowerState/'].displayStatus" \
65  --output tsv 2>/dev/null)
66
67if [ ! -z "${POWER_STATE}" ]; then
68  echo "Instance power state: ${POWER_STATE}"
69  if echo "${POWER_STATE}" | grep -qi "deallocated|stopped"; then
70    echo "Instance is deallocated or stopped. Starting instance..."
71    az vmss start \
72      --resource-group ${RESOURCE_GROUP} \
73      --name ${VMSS_NAME} \
74      --instance-ids ${INSTANCE_ID}
75  fi
76fi
77
78# Step 9: Scale up if needed (to create new instances)
79echo "To scale up the scale set (create more instances), run:"
80echo "  az vmss scale \"
81echo "    --resource-group ${RESOURCE_GROUP} \"
82echo "    --name ${VMSS_NAME} \"
83echo "    --new-capacity <desired-count>"

Related Errors

Provider Information

This error code is specific to AZURE services. For more information, refer to the official AZURE documentation.

VMSSInstanceNotFound - VMSS Instance Not Found: Instance Does Not Exist | AZURE Error Reference | Error Code Reference