简体   繁体   中英

Bulk delete blobs across multiple containers

I'm looking for an efficient way to delete a list of blobs from my storage account. There will be a "high number" of blobs to delete which are distributed throughout "many" containers.

Does the Azure Storage client library offer any mechanism to delete a List<BlobId> from my storage account? Or am I stuck with iterating over each blob, figuring out its container, and deleting individually?

Does the Azure Storage client library offer any mechanism to delete a List from my storage account?

Sadly, No. Azure Storage Client library simply offers you a Delete Blob functionality which will delete a single blob at a time.

Or am I stuck with iterating over each blob, figuring out its container, and deleting individually?

You will need to delete each blob individually. However, if you have the URL of the blob that needs to be deleted, then you don't need to figure out the container. Using the blob's URL and storage credentials, you can create an instance of CloudBlob object and then call DeleteIfExists or DeleteIfExistsAsync method to delete the blob. Something like:

        var cred = new StorageCredentials(accountName, accountKey);
        var blob = new CloudBlob(new Uri("https://myaccount.blob.core.windows.net/mycontainer/myblob.png"), cred);
        blob.DeleteIfExists();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM