Break lease on Azure Blob Storage

Tutorials

/

Posted on

July 5, 2016

I encountered an error that I've seen before when building Azure VM's in the "old" service manager or the classic portal. The issue is that sometimes when you remove the virtual machine the blobs in the storage account keep hanging around. You can easily sort that out by following this guide. Although when working with Resource Manager (ARM) virtual machines the disks are not seen in the classic portal. I can not therefore break the lease.

Error:
Failed to delete blob 'vhds/<nameofblob>.vhd'. Error: There is currently a lease on the blob and no lease ID was specified in the request.

My VM attached to the storage is removed way back and there is no other system accessing the blobs. There is a some kind of ghost lease hanging around locking the blobs. I tried several ways to remove both the blob themselves, the storage account and the whole storage account. Both through the "new" portal.azure.com and powershell but I had no success.

Solution to break lease on a blob

I tried several third party tools that can connect to Azure storage accounts and manage VHDs. For example "Azure Storage explorer 6", and "Cloudberry Explorer". Although the only tool that I found that can break leases on blobs is CloudXplorer. So in short, download CloudXplorer and follow this guide, after that there shouldn't be a lease on the blobs and you should be able to delete them or the whole storage account!

1. Visit http://clumsyleaf.com/products/cloudxplorer, then download and Install CloudXplorer.

2. Open the application CloudXplorer and click "Accounts", "New", Select Azure Blobs Accounts.

azure break lease

3. It will ask for keys, you can find the on the Storage Account on Portal.

azure break lease

4. Once Storage Account is mapped, navigate to the VHD and right-click and Break Lease.

azure break lease

5. Now you should be able to go back to the Azure portal or run commands in PowerShell to remove the blobs and/or storage account.

Good luck!

*UPDATE*

Error:
The storage account cannot be deleted due to its artifacts being in use. For more information on troubleshooting this issue, see https://azure.microsoft.com/documentation/articles/storage-cannot-delete-storage-account-container-vhd/

I've received the following error when trying to delete the storage account. This is because the container also has a lease left.

Solution to break lease on a container

You can't remove the lease on a container or storage account from CloudXplorer or any other tool I could find. I had to contact support and their backend team removed the lease. I will update this blog if I found out a command or tool that does this so you don't need to open a support case. If you don't succeed, please drop a comment or mail, and I will be happy to help, I've tried most of the "solutions" :)

Written by

Risto Lavett