Virtual Machine: Unable to Detach Locked Data Disk and Delete in Failed State

Nelsen Lim 5 Reputation points
2026-08-24T08:50:00.82+00:00

Problem description

I am trying to delete a Windows virtual machine in Azure that is currently in a 'Failed' state. The VM has a managed data disk attached, which is protected by a resource lock, preventing detachment and deletion. I want to retain this disk and delete the VM safely.

Environment

Azure Virtual Machine running Windows in resource group virtualmachine-rg, located in an unspecified region.

What I've already tried

I attempted to delete the VM via the Azure portal, but the operation failed because the disk is locked. I have not performed any further troubleshooting or lock removal steps.

Current status

The VM remains in a 'Failed' state, with the disk still attached and locked. I am seeking guidance on how to detach the locked disk so I can delete the VM while preserving the disk.

Azure Virtual Machines
Azure Virtual Machines

An Azure service that is used to provision Windows and Linux virtual machines.


1 answer

Sort by: Most helpful
  1. Jose Benjamin Solis Nolasco 11,621 Reputation points Volunteer Moderator
    2026-08-24T13:45:19.13+00:00

    Welcome to Microsoft Q&A!

    @Nelsen Lim I hope you are doing well,

    A resource lock on the managed disk prevents the disk from being deleted, but it should not normally prevent you from removing the disk from the VM configuration.

    Just take a look:

    1. Check the disk's Locks blade and identify whether it is a CanNotDelete or ReadOnly lock.
    2. If you have permission, temporarily remove the lock. A CanNotDelete lock is usually sufficient to protect the disk while allowing configuration changes.
    3. Stop/deallocate the VM if possible, then detach the data disk from the VM.
    4. Delete the VM after confirming the disk is detached.
    5. Recreate the lock on the standalone disk if you want to continue protecting it.

    If the VM remains in a Failed provisioning state and Azure does not allow the disk to be detached, don't delete or recreate the disk. First check the VM's Activity Log for the failed operation and the exact error.

    Also verify that you have the required permissions to manage both the VM and the resource lock. If the lock is inherited from the resource group or subscription, it must be addressed at that scope.

    Reference:

    Azure resource locks

    Detach a data disk from an Azure VM

    If this answer helped clarify the platform capabilities and save you troubleshooting time, please consider marking it as Accepted. This helps others in the community find similar solutions.

    Was this answer helpful?

    0 comments No comments

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.