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:
- 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.
- 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.
- 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
managedByproperty:
Delete the disk:az disk update --resource-group <ResourceGroupName> --name <DiskName> --set managedBy=""
This clears the stale VM reference and allows deletion. Option 2: Recreate a dummy VM (workaround) Only if the above options fail:az disk delete --resource-group <ResourceGroupName> --name <DiskName> --yes- Recreate a VM with the exact same resource ID (same name, RG, subscription).
- Attach the disk.
- Detach it cleanly.
- Delete the disk.
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.