Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete an Azure storage account containing a leased blob?

People also ask

How do I remove Blob storage from a lease?

Break the lease, if the container or blob has an active lease. Once a lease is broken, it cannot be renewed. Any authorized request can break the lease; the request is not required to specify a matching lease ID.

Can I delete Blob storage?

The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time with the Delete Blob operation.

What should you use to automatically delete blob from Azure Blob storage?

We are pleased to announce that we have made an Azure Logic Apps template available to expire old blobs. To set up this automated solution in your environment: Create a new Logic Apps instance, select the “Delete old Azure blobs” template, customize and run.

What is blob lease?

A lease on a blob provides exclusive write and delete access to the blob. To write to a blob with an active lease, a client must include the active lease ID with the write request.


The key to the solution is the message that the container has an active disk artifact and the advice to remove it from the repository.

The procedure to remove the disk image from the blob repository is:

  • Go to the Windows Azure Management Portal.
  • Click on Virtual Machines.
  • Click on Disks.
  • Click on the disk.
  • Click on Delete Disk.

After that, the storage account can be deleted.

Notes:

  • This applies even if you've already deleted all of your Virtual Machines and it shows 0; there still will be artifacts under the disks tab.
  • 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.

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


Unfortunately, Fernando's answer didn't work for me, since the storage was "orphan", as I deleted its VM before deleting the storage. I couldn't find a way to do it from the portal so I've installed azure-cli, and after authentication ran the following commands:

azure storage account delete <my-account>

This fails, and the error message contains the name of culprit, e.g.:

error: Storage account <my-account> has some active image(s) and/or disk(s), e.g. <my-image>. Ensure these image(s) and/or disk(s) are removed before deleting this storage

Then I deleted the offending image

azure vm disk delete <my-image>

And tried again to delete the storage, this time successfully.

azure storage account delete <my-account>


Unfortunately there is the case where the VM was deleted but Disks shows the VM attached to the blob (a 30GB VHD) precluding the deletion. Also there is the case of using the Azure Storage Explorer you find an orfan but leased VHD blob that can't be deleted and there is no reference on the Preview Portal.


Go to virtual machines, then click on discs. Mark the disc and choose delete disc at the bottom. You can now choose if you want to keep or delete the corresponding vhd.

It is important first to delete the disc via virtual machines not to delete via storage.


You can use Iaas Management Studio : break the lease, delete the blob, then remove the orphaned image.