How can i delete disk belonging to unexisting vm?

MR IT Admin 20 Reputation points
2025-12-17T17:43:31.81+00:00

I was moving a VM and some disk resources between subscriptions and it was terminated with an error. the disks were moved to the target and the vm was stuck in the source subscription.

i am able to delete the vm (and network) in the source subscription.

Now i am left with 2 disks in the target subscription that i am not able to delete as they are still attached to the source (non-existent) vm.

Similar to:

i. https://learn.microsoft.com/en-us/answers/questions/2283721/can-t-delete-disk-belonging-to-unexisting-vm?source=docs

ii. https://learn.microsoft.com/en-us/answers/questions/73592/cannot-delete-resources-because-attached-to-a-non

iii. https://learn.microsoft.com/en-us/answers/questions/1072539/cannot-delete-resources-(disks)-attached-to-a-non

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Jilakara Hemalatha 7,165 Reputation points Microsoft External Staff Moderator
    2025-12-17T21:18:11.7433333+00:00

    Hi MR IT Admin

    Thank you for reaching out Q/A out. It looks like the disks are still showing as attached to a non-existent VM due to a stale managedBy reference after the failed VM move. Here’s how you can resolve this:

    1. Check Dependencies: Sometimes, Azure retains a reference to resources even after the VM is deleted. You should ensure that the disks aren’t attached to any other existing VMs.
    2. Use the Azure Portal: Go to the Azure portal and check if there's any option to detach the disks directly:
      • Search for and select Disks from the portal.
      • Locate the disks that are causing the trouble, and check if there's an option to detach them.
    3. If the disks still appear attached but you are certain they are not in use, you can forcefully delete them using Option 1: Force detach the disk using Azure CLI (preferred) Clear the managedBy property:
         az disk update --resource-group <ResourceGroupName> --name <DiskName> --set managedBy=""
      
      Delete the disk:
         az disk delete --resource-group <ResourceGroupName> --name <DiskName>  --yes
      
      This clears the stale VM reference and allows deletion. Option 2: Recreate a dummy VM (workaround) Only if the above options fail:
      1. Recreate a VM with the exact same resource ID (same name, RG, subscription).
      2. Attach the disk.
      3. Detach it cleanly.
      4. Delete the disk.
      Please find below reference documentations:

    Find and delete unattached Azure managed and unmanaged disks by using Azure PowerShell

    Attach a managed data disk to a Windows VM by using the Azure portal

    Hope this helps! Please let me know if you have any queries.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.