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

  • Anonymous
    May 25, 2013
    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?

  • Anonymous
    June 18, 2013
    You do not need any VMs present to follow the procedure described here.

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

  • Anonymous
    November 26, 2013
    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?

  • Anonymous
    November 27, 2013
    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.

  • Anonymous
    December 01, 2013
    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?

  • Anonymous
    December 04, 2013
    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?

  • Anonymous
    December 07, 2013
    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

  • Anonymous
    February 27, 2014
    Stuck to this issue too. social.msdn.microsoft.com/.../storage-account-portalvhdszkdgbxfbsbvd3-has-containers-which-have-an-active-image-andor-disk social.technet.microsoft.com/.../storage-account-portalvhdszkdgbxfbsbvd3-has-containers-which-have-an-active-image-andor-disk

  • Anonymous
    June 06, 2014
    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.

  • Anonymous
    October 18, 2014
    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.

  • Anonymous
    May 10, 2015
    Also check it's not associated to an image.

  • Anonymous
    June 01, 2015
    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.

  • Anonymous
    June 04, 2015
    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.

  • Anonymous
    June 10, 2015
    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.  

  • Anonymous
    August 05, 2015
    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.

  • Anonymous
    November 15, 2015
    Thanks! This helped me get rid of lingering objects

  • Anonymous
    November 26, 2015
    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

  • Anonymous
    December 13, 2015
    What Rene said! - Only way I could manage to do it, no help from support.

  • Anonymous
    December 15, 2015
    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!

  • Anonymous
    December 17, 2015
    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.

  • Anonymous
    December 17, 2015
    The comment has been removed

  • Anonymous
    January 11, 2016
    Use Powershell command to delete the disks Get-AzurePublishSettingsFile Import-AzurePublishSettingsFile -PublishSettingsFile "<FilePath>" Remove-AzureDisk <DiskName>

  • Anonymous
    January 21, 2016
    Thanks Pankaj - that worked!

  • Anonymous
    January 28, 2016
    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.