BlobBatchClient Class
- java.
lang. Object - com.
azure. storage. blob. batch. BlobBatchClient
- com.
public final class BlobBatchClient
This class provides a client that contains all operations that apply to Azure Storage Blob batching.
This client offers the ability to delete and set access tier on multiple blobs at once and to submit a BlobBatch.
Method Summary
Methods inherited from java.lang.Object
Method Details
deleteBlobs
public PagedIterable<Response<Void>> deleteBlobs(List<String> blobUrls, DeleteSnapshotsOptionType deleteOptions)
Delete multiple blobs in a single request to the service.
Code samples
List<String> blobUrls = new ArrayList<>();
blobUrls.add(blobClient1.getBlobUrl());
blobUrls.add(blobClient2.getBlobUrl());
blobUrls.add(blobClient3.getBlobUrl());
try {
batchClient.deleteBlobs(blobUrls, DeleteSnapshotsOptionType.INCLUDE).forEach(response ->
System.out.printf("Deleting blob with URL %s completed with status code %d%n",
response.getRequest().getUrl(), response.getStatusCode()));
} catch (Throwable error) {
System.err.printf("Deleting blob failed with exception: %s%n", error.getMessage());
}
Parameters:
Returns:
deleteBlobs
public PagedIterable<Response<Void>> deleteBlobs(List<String> blobUrls, DeleteSnapshotsOptionType deleteOptions, Duration timeout, Context context)
Delete multiple blobs in a single request to the service.
Code samples
List<String> blobUrls = new ArrayList<>();
blobUrls.add(blobClient1.getBlobUrl());
blobUrls.add(blobClient2.getBlobUrl());
blobUrls.add(blobClient3.getBlobUrl());
try {
batchClient.deleteBlobs(blobUrls, DeleteSnapshotsOptionType.INCLUDE, timeout, Context.NONE)
.forEach(response -> System.out.printf("Deleting blob with URL %s completed with status code %d%n",
response.getRequest().getUrl(), response.getStatusCode()));
} catch (Throwable error) {
System.err.printf("Deleting blob failed with exception: %s%n", error.getMessage());
}
Parameters:
Returns:
getBlobBatch
setBlobsAccessTier
public PagedIterable<Response<Void>> setBlobsAccessTier(List<String> blobUrls, AccessTier accessTier)
Set access tier on multiple blobs in a single request to the service.
Code samples
List<String> blobUrls = new ArrayList<>();
blobUrls.add(blobClient1.getBlobUrl());
blobUrls.add(blobClient2.getBlobUrl());
blobUrls.add(blobClient3.getBlobUrl());
try {
batchClient.setBlobsAccessTier(blobUrls, AccessTier.HOT).forEach(response ->
System.out.printf("Setting blob access tier with URL %s completed with status code %d%n",
response.getRequest().getUrl(), response.getStatusCode()));
} catch (Throwable error) {
System.err.printf("Setting blob access tier failed with exception: %s%n", error.getMessage());
}
Parameters:
Returns:
setBlobsAccessTier
public PagedIterable<Response<Void>> setBlobsAccessTier(List<String> blobUrls, AccessTier accessTier, Duration timeout, Context context)
Set access tier on multiple blobs in a single request to the service.
Code samples
List<String> blobUrls = new ArrayList<>();
blobUrls.add(blobClient1.getBlobUrl());
blobUrls.add(blobClient2.getBlobUrl());
blobUrls.add(blobClient3.getBlobUrl());
try {
batchClient.setBlobsAccessTier(blobUrls, AccessTier.HOT, timeout, Context.NONE).forEach(response ->
System.out.printf("Setting blob access tier with URL %s completed with status code %d%n",
response.getRequest().getUrl(), response.getStatusCode()));
} catch (Throwable error) {
System.err.printf("Setting blob access tier failed with exception: %s%n", error.getMessage());
}
Parameters:
Returns:
submitBatch
public void submitBatch(BlobBatch batch)
Submits a batch operation.
If any request in a batch fails this will throw a BlobStorageException.
Code samples
BlobBatch batch = batchClient.getBlobBatch();
Response<Void> deleteResponse1 = batch.deleteBlob("container", "blob1");
Response<Void> deleteResponse2 = batch.deleteBlob("container", "blob2", DeleteSnapshotsOptionType.INCLUDE,
new BlobRequestConditions().setLeaseId("leaseId"));
try {
batchClient.submitBatch(batch);
System.out.println("Batch submission completed successfully.");
System.out.printf("Delete operation 1 completed with status code: %d%n", deleteResponse1.getStatusCode());
System.out.printf("Delete operation 2 completed with status code: %d%n", deleteResponse2.getStatusCode());
} catch (BlobStorageException error) {
System.err.printf("Batch submission failed. Error message: %s%n", error.getMessage());
}
Parameters:
submitBatchWithResponse
public Response<Void> submitBatchWithResponse(BlobBatch batch, boolean throwOnAnyFailure, Duration timeout, Context context)
Submits a batch operation.
If throwOnAnyFailure is true a BlobStorageException will be thrown if any request fails.
Code samples
BlobBatch batch = batchClient.getBlobBatch();
Response<Void> deleteResponse1 = batch.deleteBlob("container", "blob1");
Response<Void> deleteResponse2 = batch.deleteBlob("container", "blob2", DeleteSnapshotsOptionType.INCLUDE,
new BlobRequestConditions().setLeaseId("leaseId"));
try {
System.out.printf("Batch submission completed with status code: %d%n",
batchClient.submitBatchWithResponse(batch, true, timeout, Context.NONE).getStatusCode());
System.out.printf("Delete operation 1 completed with status code: %d%n", deleteResponse1.getStatusCode());
System.out.printf("Delete operation 2 completed with status code: %d%n", deleteResponse2.getStatusCode());
} catch (BlobStorageException error) {
System.err.printf("Batch submission failed. Error message: %s%n", error.getMessage());
}
Parameters:
Returns: