Class BlobBatch


  • public final class BlobBatch
    extends Object
    This class allows for batching of multiple Azure Storage operations in a single request via BlobBatchClient.submitBatch(BlobBatch) or BlobBatchAsyncClient.submitBatch(BlobBatch).

    Azure Storage Blob batches are homogeneous which means a delete and set tier are not allowed to be in the same batch.

     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 Detail

      • deleteBlob

        public com.azure.core.http.rest.Response<Void> deleteBlob​(String containerName,
                                                                  String blobName)
        Adds a delete blob operation to the batch.

        Code sample

         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 that will be used to associate this operation to the response when the batch is submitted.
        Throws:
        UnsupportedOperationException - If this batch has already added an operation of another type.
      • deleteBlob

        public com.azure.core.http.rest.Response<Void> deleteBlob​(String containerName,
                                                                  String blobName,
                                                                  DeleteSnapshotsOptionType deleteOptions,
                                                                  BlobRequestConditions blobRequestConditions)
        Adds a delete blob operation to the batch.

        Code sample

         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 that will be used to associate this operation to the response when the batch is submitted.
        Throws:
        UnsupportedOperationException - If this batch has already added an operation of another type.
      • deleteBlob

        public com.azure.core.http.rest.Response<Void> deleteBlob​(String blobUrl)
        Adds a delete blob operation to the batch.

        Code sample

         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 that will be used to associate this operation to the response when the batch is submitted.
        Throws:
        UnsupportedOperationException - If this batch has already added an operation of another type.
      • deleteBlob

        public com.azure.core.http.rest.Response<Void> deleteBlob​(String blobUrl,
                                                                  DeleteSnapshotsOptionType deleteOptions,
                                                                  BlobRequestConditions blobRequestConditions)
        Adds a delete blob operation to the batch.

        Code sample

         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 that will be used to associate this operation to the response when the batch is submitted.
        Throws:
        UnsupportedOperationException - If this batch has already added an operation of another type.
      • setBlobAccessTier

        public com.azure.core.http.rest.Response<Void> setBlobAccessTier​(String containerName,
                                                                         String blobName,
                                                                         AccessTier accessTier)
        Adds a set tier operation to the batch.

        Code sample

         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 that will be used to associate this operation to the response when the batch is submitted.
        Throws:
        UnsupportedOperationException - If this batch has already added an operation of another type.
      • setBlobAccessTier

        public com.azure.core.http.rest.Response<Void> setBlobAccessTier​(String containerName,
                                                                         String blobName,
                                                                         AccessTier accessTier,
                                                                         String leaseId)
        Adds a set tier operation to the batch.

        Code sample

         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 that will be used to associate this operation to the response when the batch is submitted.
        Throws:
        UnsupportedOperationException - If this batch has already added an operation of another type.
      • setBlobAccessTier

        public com.azure.core.http.rest.Response<Void> setBlobAccessTier​(String blobUrl,
                                                                         AccessTier accessTier)
        Adds a set tier operation to the batch.

        Code sample

         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 that will be used to associate this operation to the response when the batch is submitted.
        Throws:
        UnsupportedOperationException - If this batch has already added an operation of another type.
      • setBlobAccessTier

        public com.azure.core.http.rest.Response<Void> setBlobAccessTier​(String blobUrl,
                                                                         AccessTier accessTier,
                                                                         String leaseId)
        Adds a set tier operation to the batch.

        Code sample

         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 that will be used to associate this operation to the response when the batch is submitted.
        Throws:
        UnsupportedOperationException - If this batch has already added an operation of another type.
      • setBlobAccessTier

        public com.azure.core.http.rest.Response<Void> setBlobAccessTier​(BlobBatchSetBlobAccessTierOptions options)
        Adds a set tier operation to the batch.

        Code sample

         Response<Void> setTierResponse = batch.setBlobAccessTier(
             new BlobBatchSetBlobAccessTierOptions("{url of blob}", AccessTier.HOT).setLeaseId("{lease ID}"));
         
        Parameters:
        options - BlobBatchSetBlobAccessTierOptions
        Returns:
        a Response that will be used to associate this operation to the response when the batch is submitted.
        Throws:
        UnsupportedOperationException - If this batch has already added an operation of another type.