How to clean an Azure storage Blob container?

There is only one way to bulk delete blobs and that is by deleting the entire container. As you've said there is a delay between deleting the container and when you can use that container name again.

Your only other choice is to delete the one at a time. If you can do the deleting from the same data centre where the blobs are stored it will be faster than running the delete locally. This probably means writing code (or you could RDP into one of your instances and install cloud explorer). If you're writing code then you can speed up the overall process by deleting the items in parallel. Something similar to this would work:

Parallel.ForEach(myCloudBlobClient.GetContainerReference(myContainerName).ListBlobs(), x => ((CloudBlob) x).Delete());

A one liner using the Azure CLI 2.0:

az storage blob delete-batch --account-name <storage_account_name> --source <container_name>

Substitute <storage_account_name> and <container_name> by the appropriate values in your case.

You can see the help of the command by running:

az storage blob delete-batch -h

Update: Easier way to do it now (in 2018) is to use the Azure CLI. Check joanlofe's answer :)


Easiest way to do it in 2016 is using Microsoft Azure Storage Explorer IMO.

  1. Download Azure Storage Explorer and install it
  2. Sign in with the appropriate Microsoft Account
  3. Browse to the container you want to empty
  4. Click on the Select All button
  5. Click on the Delete button

Screenshot