AZURE

VMOSDiskNotFound - VM OS Disk Not Found: Disk Missing or Detached

Hitting VMOSDiskNotFound during a VM operation means ARM lost track of the OS disk—either the disk name/ID in your VM's storage profile is wrong, the disk got deleted, or it's sitting detached in your resource group. This 404 client-side error hits when ARM validates disk references before VM operations. VMs need an OS disk attached for boot and most operations. While specific to Virtual Machines, similar disk lookup failures happen in AKS node OS disks and App Service storage. The disk must exist in the same resource group or subscription and be properly referenced in the VM's storageProfile.osDisk.

#Common Causes

  • Invalid OS Disk Identifier: The disk name or ID is incorrect or contains typos. Disk identifiers must match exactly what's stored in Azure (case-sensitive). The disk reference in the VM's storageProfile.osDisk may point to a non-existent disk. This is persistent—you must use the correct identifier.
  • Deleted OS Disk: The OS disk has been deleted or doesn't exist. Deleted disks can't be attached to VMs. Disks may be deleted accidentally or during resource cleanup. This is persistent—you must create a new OS disk or use an existing one.
  • Detached OS Disk: The disk exists but isn't attached to the VM. VMs require an OS disk to be attached in the storageProfile.osDisk configuration. The disk may have been detached during VM operations or configuration changes. This is persistent—you must attach the disk to the VM.

Solutions

  1. 1Step 1: Diagnose - Get the OS disk name from the VM's storage profile: az vm show --resource-group <rg> --name <vm> --query "storageProfile.osDisk.name" --output tsv
  2. 2Step 2: Diagnose - Check if the disk exists: az disk show --resource-group <rg> --name <disk-name> --query "{Name:name,SizeGB:diskSizeGb,State:diskState,SKU:sku.name}" --output table
  3. 3Step 3: Diagnose - List all disks in the resource group to find available disks: az disk list --resource-group <rg> --query "[].{Name:name,SizeGB:diskSizeGb,State:diskState}" --output table
  4. 4Step 4: Fix - If disk identifier is wrong, use the correct disk name/ID from the disk list. Update the VM's storage profile if needed.
  5. 5Step 5: Fix - If disk was deleted, create a new OS disk: az disk create --resource-group <rg> --name <disk> --size-gb <size> --sku <sku> --os-type Linux Then attach it to the VM or recreate the VM with the new disk.
  6. 6Step 6: Fix - If disk is detached, ensure the VM's storageProfile.osDisk references the disk correctly. You may need to recreate the VM or update the disk attachment.
  7. 7Step 7: Verify - After fixing the disk reference or attaching the disk, retry your VM operation. It should succeed instead of returning VMOSDiskNotFound.

</>Code Examples

VM OS Disk Diagnosis and Management
1# This script helps diagnose VMOSDiskNotFound by checking OS disk status
2
3# Step 1: Set VM details (replace with your values)
4RESOURCE_GROUP="my-resource-group"
5VM_NAME="my-vm"
6echo "Checking OS disk for VM: ${VM_NAME}"
7
8# Step 2: Get VM OS disk details from storage profile
9echo "Getting OS disk details from VM storage profile..."
10az vm show \
11  --resource-group ${RESOURCE_GROUP} \
12  --name ${VM_NAME} \
13  --query "storageProfile.osDisk" \
14  --output table
15
16# Step 3: Get OS disk name
17echo "Extracting OS disk name..."
18OS_DISK_NAME=$(az vm show \
19  --resource-group ${RESOURCE_GROUP} \
20  --name ${VM_NAME} \
21  --query "storageProfile.osDisk.name" \
22  --output tsv)
23
24if [ ! -z "${OS_DISK_NAME}" ]; then
25  echo "OS Disk name: ${OS_DISK_NAME}"
26else
27  echo "WARNING: No OS disk name found in VM storage profile"
28fi
29
30# Step 4: Check if disk exists
31if [ ! -z "${OS_DISK_NAME}" ]; then
32  echo "Checking if disk exists..."
33  if az disk show \
34    --resource-group ${RESOURCE_GROUP} \
35    --name ${OS_DISK_NAME} \
36    --query "{Name:name,SizeGB:diskSizeGb,State:diskState,SKU:sku.name,ProvisioningState:provisioningState}" \
37    --output table 2>&1; then
38    echo "OS disk exists and is accessible"
39  else
40    echo "ERROR: OS disk ${OS_DISK_NAME} not found"
41    echo "The disk may have been deleted or doesn't exist"
42  fi
43fi
44
45# Step 5: List all disks in resource group
46echo "Listing all disks in resource group..."
47az disk list \
48  --resource-group ${RESOURCE_GROUP} \
49  --query "[].{Name:name,SizeGB:diskSizeGb,State:diskState,SKU:sku.name}" \
50  --output table
51
52# Step 6: Get disk by ID if you have the full resource ID
53if [ ! -z "${OS_DISK_NAME}" ]; then
54  DISK_ID="/subscriptions/$(az account show --query id -o tsv)/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Compute/disks/${OS_DISK_NAME}"
55  echo "Checking disk by full resource ID: ${DISK_ID}"
56  az disk show \
57    --ids ${DISK_ID} \
58    --query "{Name:name,SizeGB:diskSizeGb,State:diskState}" \
59    --output table 2>&1 || echo "Disk not found by ID"
60fi
61
62# Step 7: Instructions for creating new OS disk if needed
63echo ""
64echo "If OS disk is missing, create a new one:"
65echo "  az disk create \"
66echo "    --resource-group ${RESOURCE_GROUP} \"
67echo "    --name <new-disk-name> \"
68echo "    --size-gb <size> \"
69echo "    --sku <sku> \"
70echo "    --os-type Linux"
71echo ""
72echo "Note: You may need to recreate the VM or update the storage profile to attach the new disk"

Related Errors

Provider Information

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

VMOSDiskNotFound - VM OS Disk Not Found: Disk Missing or Detached | AZURE Error Reference | Error Code Reference