How to do a bulk delete on blobs in a blob storage using java

Kosala De Silva 41 Reputation points
2020-09-03T05:44:01.867+00:00

I have blobs which I want to delete via java application.

eg:
translation/2020/en/MOD1-en.zip
translation/2020/en/MOD2-en.zip
translation/2020/en/MOD3-en.zip
translation/2020/de/MOD1-de.zip
translation/2020/de/MOD1-de.zip

I want to delete all blobs starting with "translation/2020/en".
today what I do is deleting the files one by one.

code:

  final ListBlobsOptions listBlobsOptions =
          new ListBlobsOptions().setPrefix("translation/2020/en/");

  for (BlobItem blobItem : releaseContainer.listBlobs(listBlobsOptions, Duration.ofSeconds(60))) {
     final BlobClient sourceBlobClient = releaseContainer.getBlobClient(blobItem.getName());
     sourceBlobClient.delete();
  }

Is there a easy way to do this without deleting the blobs one by one?

Any help regarding this is much appreciated.
/Kosala

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,192 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sumarigo-MSFT 47,466 Reputation points Microsoft Employee Moderator
    2020-09-03T09:21:00.643+00:00

    @Kosala De Silva For better understanding: Have you referred Delete multiple blobs in a single request to the service.

    For more information: Please refer to this article:

    Bulk Deleting Blobs

    Hope this helps!Kindly let us know if the above helps or you need further assistance on this issue.

    -----------------------------------------------------------------------------------------------------------------------

    Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.