I am using azure blob storage to store my project files.
I have a service account of azure blob storage(client_id and client_secret).I have created CloudBlobClient
using StorageCredentialsToken
as below:
StorageCredentialsToken credentialsToken = new StorageCredentialsToken("account name", "access token generated uing client_id and client_secret");
CloudBlobClient blobClient = new CloudBlobClient(new URI("https://accountname.blob.core.windows.net/"), credentialsToken);
CloudBlobContainer cloudBlobContainer = blobClient.getContainerReference("conteiner name");
Now using CloudBlobContainer
I can delete one file at a time:
CloudBlockBlob blockBlobReference = cloudBlobContainer.getBlockBlobReference(key);
if (blockBlobReference.exists()) {
blockBlobReference.delete();
}
How can I delete multiple files using a single call?
I find this doc which says we can delete multiple files with BlobBatchClient
. In the document, I can not find any ways to create BlobBatchClient
using a service account(using access token obtained by client_id and client_secret).
Can we delete files in async call as I need to delete 100s of files? Any alternative solutions to delete files in batch?
SDK version compile group: 'com.microsoft.azure', name: 'azure-storage', version: '8.6.5'
As per comment by Jim, I have created
BlobServiceAsyncClient
using access token sample method:Gradle dependencies: