Unable to delete VHD, “There is currently a lease on the blob…”


For classic VMs, there are artifacts (metadata about the VHDs) that keep a lease on the VHD even when no VM is using it.

To delete a disk or image for classic VMs, in the classic portal (https://manage.windowsazure.com/) select Virtual Machines on the left navigation pane, then select the Disks or Images tab on the right pane.

There are two types of images for classic VMs - OS images (the original type) and VM images (became available in 2014). But currently the new portal's VM Images (classic) section only shows VM images but not OS images. This is a known issue and an update is planned to allow managing both types of images for classic VMs in the new portal, but in the meantime, use the classic portal to remove the older type of images (OS images).

If you are unable to delete a storage account and the error references "artifacts", you need to remove the disk and image metadata as mentioned above. Even if you manually break the lease and delete the VHD blob, the artifacts (metadata for the disk or image) still exist and prevent you from deleting the storage account. That is why you must remove them as recommended, and just deleting the VHD blobs in Azure storage is not enough to allow the storage account to be removed.

Scenario:

After deleting a Windows Azure Virtual Machine you try to delete the blobs for the associated VHDs and receive the message below:

"There is currently a lease on the blob and no lease ID was specified in the request."

 

Root Cause:

When you delete a Virtual Machine on the Management Portal, the "Disk" resource used to mount the Virtual Machines VHD is kept.

The "Disk" resource is responsible for mounting the blob for the VHD file, so it can be attached to virtual machines as an OS Disk or Data Disk. It will continue to hold a lease on the blob for as long as it exists.

 

Resolution:

You need to delete the "Disk" resource to break the lease on the blob.

All Disks resources are found on the Management Portal under: Virtual Machines -> Disks

To delete the Disk resource follow the steps below:

  1. On the Azure Management Portal, navigate to Virtual Machines -> Disks
  2. Select the Disk you want to delete.
  3. Confirm there is no Virtual Machine listed on the "Attached to" column
    1. Disks are detached from a deleted VM asynchronously, it may take a few minutes after the VM is deleted for this field to clear up.
  4. Click "Delete" and choose if you want to "Retain the associated VHD" or "Delete the associated VHD"
    1. If you choose to "Retain the associated VHD" the lease will be removed but the blog containing the VHD will be kept in your Storage Account. You may choose this option if you plan to delete the VHD directly from your storage account VHDs container, create a new Disk pointing to the existing VHD, download to your on-premises environment or just leave it there for future use.

 

References:

How to Attach a Data Disk to a Virtual Machine
How to Detach a Data Disk from a Virtual Machine

 

Hope it helps.

Flavio Muratore
Sr. Support Escalation Engineer
Windows Azure Technical Support

Comments (25)

  1. What if you have already deleted the VM? says:

    I accidentally deleted the VM first and then tried to delete the disk and got the "There is currently a lease on the blob…" error. How do I now go delete the blob if there is no VM associated with it any more?

  2. You do not need any VMs present to follow the procedure described here.

  3. Kris Spencer says:

    This doesn't work if the blog  is attached to a non existent VM.. Thanks for another useless piece of documentation from microsoft!

  4. Mike says:

    Same issue here, DISK can't be deleted because it is attached to a no longer existing VM.

    How do we delete a disk pointing to a no longer existing VM?

  5. Gary says:

    Same issue here. Seems impossible to delete the VHD when azure thinks its still attached to a VM, and the VM no longer exists. One of several severe flaws we've found with Azure.

  6. Dave says:

    Same issue here too. DIsk cannot be deleted as the option is greyed out. The Management Portal reports that the disk is attached to a VM but this VM was deleted a week ago. How can I delete the disk?

  7. Crispy says:

    Same Problem here. VM, deployment and Service are no longer available. Now im stuck with my VHD. Can't delete it with the Management Portal, the System Center App Controller nor azure powershell cmdlets.

    Do i have to open a Support case for this?

  8. Kaysoft says:

    I ended up begging TECH SUPPORT as I was on FREE TRIAL to help clearing the ATTACHED-TO field and was able to cleanup disks.

    See: social.msdn.microsoft.com/…/data-disk-is-still-attached-to-deleted-vm

  9. StephenP says:

    This guide appears to work as described. A virtual machine does not need to be present in order to remove the associated disk(s) — as in my case.

  10. WDPhillips says:

    I already deleted the VM and still couldn't delete the blob. I went back to the VM list and hit Disks. The disk was still there. Removed it there and all good. Not sure if it's a bug or a feature. Would be good if you accidentally removed it.

  11. BevanM says:

    Also check it's not associated to an image.

  12. Mani says:

    We always look for disks inside VM, so when the vm deleted I could not delete the vhd, because the disk were still there.  I have not noticed the DISK tab at all. Thanks… it works fine.

  13. Alex Verboon says:

    Thanks, worked. Unfortunately you have to use the old azure portal, as there is no option to delete a disk in the new portal yet.

  14. Z says:

    It appears as if there is some kind of timer job that clears up leases after you delete a VM or just remove it from the VM.  Usually gives me the lease error message for about 20-30 min.  

  15. Luis Forero says:

    Create a new VM pointing to the existing VHD  if you have more VHD  with the same problem you may atach one to this VM. When you are finish delete the virtual machin MAKE SURE you delete the atthached VHDs.

  16. Jonas Akrouh Larsen says:

    Thanks! This helped me get rid of lingering objects

  17. René Sluiter says:

    make sure you are on the 'old' dashboard page to remove the disks.

    it is possible on manage.windowsazure.com

    not possible on on the Azure Preview Portal https://portal.azure.com

  18. Brendan Elding says:

    What Rene said! – Only way I could manage to do it, no help from support.

  19. Andi Vi says:

    Great, now Microsoft killed the option to delete "corrupt" Storage Blobs in the old dashboard. It always refers to the new preview portal where it is not possible ot delte the unused storage blob. Nice.. so I am paying for nothing.. good way to make money Microsoft!

  20. Greg says:

    Can somebody please explain how to delete a blob now the old portal has gone? I have deleted a VM yet a number of disks still exist which I cannot delete.

    There must be a away without contacting support. I have tried to create a new VM, attach/detach and delete but that does not work.

  21. Greg says:

    scrap that, had a typo in the old portal URL.

    Cant believe this option is not in place within the new portal

  22. Pankaj says:

    Use Powershell command to delete the disks

    Get-AzurePublishSettingsFile

    Import-AzurePublishSettingsFile -PublishSettingsFile "<FilePath>"

    Remove-AzureDisk <DiskName>

  23. Peter says:

    Thanks Pankaj – that worked!

  24. PavelFlores says:

    Greg you can browse all items in the menu and search disk, then select OS disks (classic) and then erase os disks, then you can erase de blobs.

    hope help.

Skip to main content