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'
BlobServiceClient
using the service account (StorageCredentialsToken
) ref: github.com/Azure/azure-sdk-for-java/tree/master/sdk/storage/… – NitinStorageSharedKeyCredential
with account_name and account_key to create BlobServiceClient. – Pamela PengStorageCredentialsToken
has been removed. If you want to use Azure AD auth to access blob, we need to provide aTokenCredential
object. For more details, please refer to github.com/Azure/azure-sdk-for-java/issues/6509 – Jim XuStorageSharedKeyCredential
we need accountKey. what is accountKey here? I tried with passing access token generated using client_id and client_secret but it is giving errorjava.lang.IllegalArgumentException: Illegal base64 character 2e
It can not decode the access token – Nitin