Deleting Azure Storage Accounts with Leased Blobs
When working with Azure, you may encounter issues when trying to delete a storage account that still contains leased blobs. This often occurs after deleting a virtual machine (VM) that was using the associated storage. Below are the steps to resolve this issue.
Understanding the Problem
After successfully deleting a VM, you might attempt to delete its associated storage account only to receive an error message indicating that the storage account cannot be deleted due to active artifacts:
Failed to delete Storage account 'your_storage_account_name'
Details:
Storage account your_storage_account_name has 1 container(s) which have an active image and/or disk artifacts. Ensure those artifacts are removed from the image repository before deleting this storage account.
This error typically means that there are still blobs (like VHD files) in the storage account that are leased, preventing their deletion.
Steps to Resolve the Issue
Identify Leased Blobs:
- Sign in to the Azure portal.
- Navigate to the storage account and select the relevant container.
- Check the metadata of the blobs. If the
Lease Stateis marked asLeased, you will need to break the lease before proceeding.
Break the Lease on the Blob:
- Right-click on the blob and select the option to Break lease. This action will allow you to modify or delete the blob.
Delete the Blob:
- Once the lease is broken, you can delete the blob directly from the Azure portal or using Azure Storage Explorer.
- If you are using Azure Storage Explorer, you might encounter an error stating:
There is currently a lease on the blob and no lease ID was specified in the request.Ensure that the lease has been successfully broken before attempting deletion again.
Delete the Storage Account:
- After all blobs have been deleted, you can now proceed to delete the storage account without encountering errors.
Conclusion
By following these steps, you should be able to successfully delete a storage account that contains leased blobs. Always ensure that all dependencies are resolved before attempting to delete resources in Azure to avoid such issues in the future.