BlobBatch Class

  • java.lang.Object
    • com.azure.storage.blob.batch.BlobBatch

public final class BlobBatch

This class allows for batching of multiple Azure Storage operations in a single request via submitBatch(BlobBatch batch) or submitBatch(BlobBatch batch).

Azure Storage Blob batches are homogeneous which means a deleteBlob(String blobUrl) and setBlobAccessTier(String blobUrl, AccessTier accessTier) are not allowed to be in the same batch.

Java
try {
     Response<Void> deleteResponse = batch.deleteBlob("{url of blob}");
     Response<Void> setTierResponse = batch.setBlobAccessTier("{url of another blob}", AccessTier.HOT);
 } catch (UnsupportedOperationException ex) {
     System.err.printf("This will fail as Azure Storage Blob batch operations are homogeneous. Exception: %s%n",
         ex.getMessage());
 }

Please refer to the Azure Docs for more information.

Method Summary

Methods inherited from java.lang.Object

Method Details

deleteBlob

public Response deleteBlob(String blobUrl)

Adds a delete blob operation to the batch.

Code sample

Java
Response<Void> deleteResponse = batch.deleteBlob("{url of blob}");

Parameters:

blobUrl - URL of the blob. Blob name must be encoded to UTF-8.

Returns:

a Response<T> that will be used to associate this operation to the response when the batch is submitted.

deleteBlob

public Response deleteBlob(String blobUrl, DeleteSnapshotsOptionType deleteOptions, BlobRequestConditions blobRequestConditions)

Adds a delete blob operation to the batch.

Code sample

Java
BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId("{lease ID}");

 Response<Void> deleteResponse = batch.deleteBlob("{url of blob}", DeleteSnapshotsOptionType.INCLUDE,
     blobRequestConditions);

Parameters:

blobUrl - URL of the blob. Blob name must be encoded to UTF-8.
deleteOptions - Delete options for the blob and its snapshots.
blobRequestConditions - Additional access conditions that must be met to allow this operation.

Returns:

a Response<T> that will be used to associate this operation to the response when the batch is submitted.

deleteBlob

public Response deleteBlob(String containerName, String blobName)

Adds a delete blob operation to the batch.

Code sample

Java
Response<Void> deleteResponse = batch.deleteBlob("{container name}", "{blob name}");

Parameters:

containerName - The container of the blob.
blobName - The name of the blob.

Returns:

a Response<T> that will be used to associate this operation to the response when the batch is submitted.

deleteBlob

public Response deleteBlob(String containerName, String blobName, DeleteSnapshotsOptionType deleteOptions, BlobRequestConditions blobRequestConditions)

Adds a delete blob operation to the batch.

Code sample

Java
BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId("{lease ID}");

 Response<Void> deleteResponse = batch.deleteBlob("{container name}", "{blob name}",
     DeleteSnapshotsOptionType.INCLUDE, blobRequestConditions);

Parameters:

containerName - The container of the blob.
blobName - The name of the blob.
deleteOptions - Delete options for the blob and its snapshots.
blobRequestConditions - Additional access conditions that must be met to allow this operation.

Returns:

a Response<T> that will be used to associate this operation to the response when the batch is submitted.

setBlobAccessTier

public Response setBlobAccessTier(BlobBatchSetBlobAccessTierOptions options)

Adds a set tier operation to the batch.

Code sample

Java
Response<Void> setTierResponse = batch.setBlobAccessTier(
     new BlobBatchSetBlobAccessTierOptions("{url of blob}", AccessTier.HOT).setLeaseId("{lease ID}"));

Parameters:

Returns:

a Response<T> that will be used to associate this operation to the response when the batch is submitted.

setBlobAccessTier

public Response setBlobAccessTier(String blobUrl, AccessTier accessTier)

Adds a set tier operation to the batch.

Code sample

Java
Response<Void> setTierResponse = batch.setBlobAccessTier("{url of blob}", AccessTier.HOT);

Parameters:

blobUrl - URL of the blob. Blob name must be encoded to UTF-8.
accessTier - The tier to set on the blob.

Returns:

a Response<T> that will be used to associate this operation to the response when the batch is submitted.

setBlobAccessTier

public Response setBlobAccessTier(String blobUrl, AccessTier accessTier, String leaseId)

Adds a set tier operation to the batch.

Code sample

Java
Response<Void> setTierResponse = batch.setBlobAccessTier("{url of blob}", AccessTier.HOT, "{lease ID}");

Parameters:

blobUrl - URL of the blob. Blob name must be encoded to UTF-8.
accessTier - The tier to set on the blob.
leaseId - The lease ID the active lease on the blob must match.

Returns:

a Response<T> that will be used to associate this operation to the response when the batch is submitted.

setBlobAccessTier

public Response setBlobAccessTier(String containerName, String blobName, AccessTier accessTier)

Adds a set tier operation to the batch.

Code sample

Java
Response<Void> setTierResponse = batch.setBlobAccessTier("{container name}", "{blob name}", AccessTier.HOT);

Parameters:

containerName - The container of the blob.
blobName - The name of the blob.
accessTier - The tier to set on the blob.

Returns:

a Response<T> that will be used to associate this operation to the response when the batch is submitted.

setBlobAccessTier

public Response setBlobAccessTier(String containerName, String blobName, AccessTier accessTier, String leaseId)

Adds a set tier operation to the batch.

Code sample

Java
Response<Void> setTierResponse = batch.setBlobAccessTier("{container name}", "{blob name}", AccessTier.HOT,
     "{lease ID}");

Parameters:

containerName - The container of the blob.
blobName - The name of the blob.
accessTier - The tier to set on the blob.
leaseId - The lease ID the active lease on the blob must match.

Returns:

a Response<T> that will be used to associate this operation to the response when the batch is submitted.

Applies to

Azure SDK for Java

Latest