Class BlobAsyncClientBase

java.lang.Object
com.azure.storage.blob.specialized.BlobAsyncClientBase
Direct Known Subclasses:
AppendBlobAsyncClient, BlobAsyncClient, BlockBlobAsyncClient, PageBlobAsyncClient

public class BlobAsyncClientBase extends Object
This class provides a client that contains all operations that apply to any blob type.

This client offers the ability to download blobs. Note that uploading data is specific to each type of blob. Please refer to the BlockBlobClient, PageBlobClient, or AppendBlobClient for upload options.

  • Field Details

    • azureBlobStorage

      protected final com.azure.storage.blob.implementation.AzureBlobStorageImpl azureBlobStorage
      Backing REST client for the blob client.
    • encryptionScope

      protected final com.azure.storage.blob.implementation.models.EncryptionScope encryptionScope
      Encryption scope of the blob.
    • accountName

      protected final String accountName
      Storage account name that contains the blob.
    • containerName

      protected final String containerName
      Container name that contains the blob.
    • blobName

      protected final String blobName
      Name of the blob.
    • serviceVersion

      protected final BlobServiceVersion serviceVersion
      Storage REST API version used in requests to the Storage service.
  • Constructor Details

    • BlobAsyncClientBase

      protected BlobAsyncClientBase(com.azure.core.http.HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey)
      Protected constructor for use by SpecializedBlobClientBuilder.
      Parameters:
      pipeline - The pipeline used to send and receive service requests.
      url - The endpoint where to send service requests.
      serviceVersion - The version of the service to receive requests.
      accountName - The storage account name.
      containerName - The container name.
      blobName - The blob name.
      snapshot - The snapshot identifier for the blob, pass null to interact with the blob directly.
      customerProvidedKey - Customer provided key used during encryption of the blob's data on the server, pass null to allow the service to use its own encryption.
    • BlobAsyncClientBase

      protected BlobAsyncClientBase(com.azure.core.http.HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, com.azure.storage.blob.implementation.models.EncryptionScope encryptionScope)
      Protected constructor for use by SpecializedBlobClientBuilder.
      Parameters:
      pipeline - The pipeline used to send and receive service requests.
      url - The endpoint where to send service requests.
      serviceVersion - The version of the service to receive requests.
      accountName - The storage account name.
      containerName - The container name.
      blobName - The blob name.
      snapshot - The snapshot identifier for the blob, pass null to interact with the blob directly.
      customerProvidedKey - Customer provided key used during encryption of the blob's data on the server, pass null to allow the service to use its own encryption.
      encryptionScope - Encryption scope used during encryption of the blob's data on the server, pass null to allow the service to use its own encryption.
    • BlobAsyncClientBase

      protected BlobAsyncClientBase(com.azure.core.http.HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, com.azure.storage.blob.implementation.models.EncryptionScope encryptionScope, String versionId)
      Protected constructor for use by SpecializedBlobClientBuilder.
      Parameters:
      pipeline - The pipeline used to send and receive service requests.
      url - The endpoint where to send service requests.
      serviceVersion - The version of the service to receive requests.
      accountName - The storage account name.
      containerName - The container name.
      blobName - The blob name.
      snapshot - The snapshot identifier for the blob, pass null to interact with the blob directly.
      customerProvidedKey - Customer provided key used during encryption of the blob's data on the server, pass null to allow the service to use its own encryption.
      encryptionScope - Encryption scope used during encryption of the blob's data on the server, pass null to allow the service to use its own encryption.
      versionId - The version identifier for the blob, pass null to interact with the latest blob version.
  • Method Details

    • getEncryptionScope

      protected String getEncryptionScope()
      Gets the encryption scope used to encrypt this blob's content on the server.
      Returns:
      the encryption scope used for encryption.
    • getSnapshotClient

      public BlobAsyncClientBase getSnapshotClient(String snapshot)
      Creates a new BlobAsyncClientBase linked to the snapshot of this blob resource.
      Parameters:
      snapshot - the identifier for a specific snapshot of this blob
      Returns:
      a BlobAsyncClientBase used to interact with the specific snapshot.
    • getVersionClient

      public BlobAsyncClientBase getVersionClient(String versionId)
      Creates a new BlobAsyncClientBase linked to the versionId of this blob resource.
      Parameters:
      versionId - the identifier for a specific version of this blob, pass null to interact with the latest blob version.
      Returns:
      a BlobAsyncClientBase used to interact with the specific version.
    • getEncryptionScopeAsyncClient

      public BlobAsyncClientBase getEncryptionScopeAsyncClient(String encryptionScope)
      Creates a new BlobAsyncClientBase with the specified encryptionScope.
      Parameters:
      encryptionScope - the encryption scope for the blob, pass null to use no encryption scope.
      Returns:
      a BlobAsyncClientBase with the specified encryptionScope.
    • getCustomerProvidedKeyAsyncClient

      public BlobAsyncClientBase getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey)
      Creates a new BlobAsyncClientBase with the specified customerProvidedKey.
      Parameters:
      customerProvidedKey - the CustomerProvidedKey for the blob, pass null to use no customer provided key.
      Returns:
      a BlobAsyncClientBase with the specified customerProvidedKey.
    • getAccountUrl

      public String getAccountUrl()
      Get the url of the storage account.
      Returns:
      the URL of the storage account
    • getBlobUrl

      public String getBlobUrl()
      Gets the URL of the blob represented by this client.
      Returns:
      the URL.
    • getContainerName

      public final String getContainerName()
      Get the container name.

      Code Samples

       String containerName = client.getContainerName();
       System.out.println("The name of the container is " + containerName);
       
      Returns:
      The name of the container.
    • getContainerAsyncClient

      public BlobContainerAsyncClient getContainerAsyncClient()
      Get an async client pointing to the parent container.

      Code Samples

       BlobContainerAsyncClient containerClient = client.getContainerAsyncClient();
       System.out.println("The name of the container is " + containerClient.getBlobContainerName());
       
      Returns:
      BlobContainerAsyncClient
    • getBlobName

      public final String getBlobName()
      Decodes and gets the blob name.

      Code Samples

       String blobName = client.getBlobName();
       System.out.println("The name of the blob is " + blobName);
       
      Returns:
      The decoded name of the blob.
    • getHttpPipeline

      public com.azure.core.http.HttpPipeline getHttpPipeline()
      Gets the HttpPipeline powering this client.
      Returns:
      The pipeline.
    • getCustomerProvidedKey

      public CpkInfo getCustomerProvidedKey()
      Gets the CpkInfo used to encrypt this blob's content on the server.
      Returns:
      the customer provided key used for encryption.
    • getAccountName

      public String getAccountName()
      Get associated account name.
      Returns:
      account name associated with this storage resource.
    • getServiceVersion

      public BlobServiceVersion getServiceVersion()
      Gets the service version the client is using.
      Returns:
      the service version the client is using.
    • getSnapshotId

      public String getSnapshotId()
      Gets the snapshotId for a blob resource
      Returns:
      A string that represents the snapshotId of the snapshot blob
    • isSnapshot

      public boolean isSnapshot()
      Determines if a blob is a snapshot
      Returns:
      A boolean that indicates if a blob is a snapshot
    • getVersionId

      public String getVersionId()
      Gets the versionId for a blob resource
      Returns:
      A string that represents the versionId of the snapshot blob
    • exists

      public Mono<Boolean> exists()
      Determines if the blob this client represents exists in the cloud.

      Code Samples

       client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
       
      Returns:
      true if the blob exists, false if it doesn't
    • existsWithResponse

      public Mono<com.azure.core.http.rest.Response<Boolean>> existsWithResponse()
      Determines if the blob this client represents exists in the cloud.

      Code Samples

       client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));
       
      Returns:
      true if the blob exists, false if it doesn't
    • beginCopy

      public com.azure.core.util.polling.PollerFlux<BlobCopyInfo,Void> beginCopy(String sourceUrl, Duration pollInterval)
      Copies the data at the source URL to a blob.

      This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If the source is in another account, the source must either be public or authenticated with a SAS token. If the source is in the same account, the Shared Key authorization on the destination will also be applied to the source. The source URL must be URL encoded.

      Code Samples

       client.beginCopy(url, Duration.ofSeconds(3))
           .subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
       

      For more information, see the Azure Docs

      Parameters:
      sourceUrl - The source URL to copy from. URLs outside of Azure may only be copied to block blobs.
      pollInterval - Duration between each poll for the copy status. If none is specified, a default of one second is used.
      Returns:
      A PollerFlux that polls the blob copy operation until it has completed, has failed, or has been cancelled.
    • beginCopy

      public com.azure.core.util.polling.PollerFlux<BlobCopyInfo,Void> beginCopy(String sourceUrl, Map<String,String> metadata, AccessTier tier, RehydratePriority priority, com.azure.core.http.RequestConditions sourceModifiedRequestConditions, BlobRequestConditions destRequestConditions, Duration pollInterval)
      Copies the data at the source URL to a blob.

      This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If the source is in another account, the source must either be public or authenticated with a SAS token. If the source is in the same account, the Shared Key authorization on the destination will also be applied to the source. The source URL must be URL encoded.

      Starting a copy operation

      Starting a copy operation and polling on the responses.
       Map<String, String> metadata = Collections.singletonMap("metadata", "value");
       RequestConditions modifiedRequestConditions = new RequestConditions()
           .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
       BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
      
       client.beginCopy(url, metadata, AccessTier.HOT, RehydratePriority.STANDARD,
           modifiedRequestConditions, blobRequestConditions, Duration.ofSeconds(2))
           .subscribe(response -> {
               BlobCopyInfo info = response.getValue();
               System.out.printf("CopyId: %s. Status: %s%n", info.getCopyId(), info.getCopyStatus());
           });
       

      For more information, see the Azure Docs

      Parameters:
      sourceUrl - The source URL to copy from. URLs outside of Azure may only be copied to block blobs.
      metadata - Metadata to associate with the destination blob. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
      tier - AccessTier for the destination blob.
      priority - RehydratePriority for rehydrating the blob.
      sourceModifiedRequestConditions - RequestConditions against the source. Standard HTTP Access conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given request. The request will fail if the specified condition is not satisfied.
      destRequestConditions - BlobRequestConditions against the destination.
      pollInterval - Duration between each poll for the copy status. If none is specified, a default of one second is used.
      Returns:
      A PollerFlux that polls the blob copy operation until it has completed, has failed, or has been cancelled.
    • beginCopy

      public com.azure.core.util.polling.PollerFlux<BlobCopyInfo,Void> beginCopy(BlobBeginCopyOptions options)
      Copies the data at the source URL to a blob.

      This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If the source is in another account, the source must either be public or authenticated with a SAS token. If the source is in the same account, the Shared Key authorization on the destination will also be applied to the source. The source URL must be URL encoded.

      Starting a copy operation

      Starting a copy operation and polling on the responses.
       Map<String, String> metadata = Collections.singletonMap("metadata", "value");
       Map<String, String> tags = Collections.singletonMap("tag", "value");
       BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions()
           .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
       BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
      
       client.beginCopy(new BlobBeginCopyOptions(url).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT)
           .setRehydratePriority(RehydratePriority.STANDARD).setSourceRequestConditions(modifiedRequestConditions)
           .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2)))
           .subscribe(response -> {
               BlobCopyInfo info = response.getValue();
               System.out.printf("CopyId: %s. Status: %s%n", info.getCopyId(), info.getCopyStatus());
           });
       

      Cancelling a copy operation

       Map<String, String> metadata = Collections.singletonMap("metadata", "value");
       Map<String, String> tags = Collections.singletonMap("tag", "value");
       BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions()
           .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
       BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
      
       PollerFlux<BlobCopyInfo, Void> poller = client.beginCopy(new BlobBeginCopyOptions(url)
           .setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT)
           .setRehydratePriority(RehydratePriority.STANDARD).setSourceRequestConditions(modifiedRequestConditions)
           .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2)));
      
       poller.take(Duration.ofMinutes(30))
               .last()
               .flatMap(asyncPollResponse -> {
                   if (!asyncPollResponse.getStatus().isComplete()) {
                       return asyncPollResponse
                               .cancelOperation()
                               .then(Mono.error(new RuntimeException("Blob copy taking long time, "
                                       + "operation is cancelled!")));
                   }
                   return Mono.just(asyncPollResponse);
               }).block();
       

      For more information, see the Azure Docs

      Parameters:
      options - BlobBeginCopyOptions
      Returns:
      A PollerFlux that polls the blob copy operation until it has completed, has failed, or has been cancelled.
    • abortCopyFromUrl

      public Mono<Void> abortCopyFromUrl(String copyId)
      Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata.

      Code Samples

       client.abortCopyFromUrl(copyId).doOnSuccess(response -> System.out.println("Aborted copy from URL"));
       

      For more information, see the Azure Docs

      Parameters:
      copyId - The id of the copy operation to abort.
      Returns:
      A reactive response signalling completion.
      See Also:
    • abortCopyFromUrlWithResponse

      public Mono<com.azure.core.http.rest.Response<Void>> abortCopyFromUrlWithResponse(String copyId, String leaseId)
      Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata.

      Code Samples

       client.abortCopyFromUrlWithResponse(copyId, leaseId)
           .subscribe(response -> System.out.printf("Aborted copy completed with status %d%n", response.getStatusCode()));
       

      For more information, see the Azure Docs

      Parameters:
      copyId - The id of the copy operation to abort.
      leaseId - The lease ID the active lease on the blob must match.
      Returns:
      A reactive response signalling completion.
      See Also:
    • copyFromUrl

      public Mono<String> copyFromUrl(String copySource)
      Copies the data at the source URL to a blob and waits for the copy to complete before returning a response.

      The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token attached. The URL must be URL encoded.

      Code Samples

       client.copyFromUrl(url).subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
       

      For more information, see the Azure Docs

      Parameters:
      copySource - The source URL to copy from.
      Returns:
      A reactive response containing the copy ID for the long-running operation.
    • copyFromUrlWithResponse

      public Mono<com.azure.core.http.rest.Response<String>> copyFromUrlWithResponse(String copySource, Map<String,String> metadata, AccessTier tier, com.azure.core.http.RequestConditions sourceModifiedRequestConditions, BlobRequestConditions destRequestConditions)
      Copies the data at the source URL to a blob and waits for the copy to complete before returning a response.

      The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token attached. The URL must be URL encoded.

      Code Samples

       Map<String, String> metadata = Collections.singletonMap("metadata", "value");
       RequestConditions modifiedRequestConditions = new RequestConditions()
           .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
       BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
      
       client.copyFromUrlWithResponse(url, metadata, AccessTier.HOT, modifiedRequestConditions, blobRequestConditions)
           .subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
       

      For more information, see the Azure Docs

      Parameters:
      copySource - The source URL to copy from. URLs outside of Azure may only be copied to block blobs.
      metadata - Metadata to associate with the destination blob. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
      tier - AccessTier for the destination blob.
      sourceModifiedRequestConditions - RequestConditions against the source. Standard HTTP Access conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given request. The request will fail if the specified condition is not satisfied.
      destRequestConditions - BlobRequestConditions against the destination.
      Returns:
      A reactive response containing the copy ID for the long-running operation.
    • copyFromUrlWithResponse

      public Mono<com.azure.core.http.rest.Response<String>> copyFromUrlWithResponse(BlobCopyFromUrlOptions options)
      Copies the data at the source URL to a blob and waits for the copy to complete before returning a response.

      The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token attached. The URL must be URL encoded.

      Code Samples

       Map<String, String> metadata = Collections.singletonMap("metadata", "value");
       Map<String, String> tags = Collections.singletonMap("tag", "value");
       RequestConditions modifiedRequestConditions = new RequestConditions()
           .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
       BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
      
       client.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(url).setMetadata(metadata).setTags(tags)
           .setTier(AccessTier.HOT).setSourceRequestConditions(modifiedRequestConditions)
           .setDestinationRequestConditions(blobRequestConditions))
           .subscribe(response -> System.out.printf("Copy identifier: %s%n", response));
       

      For more information, see the Azure Docs

      Parameters:
      options - BlobCopyFromUrlOptions
      Returns:
      A reactive response containing the copy ID for the long-running operation.
    • download

      @Deprecated public Flux<ByteBuffer> download()
      Deprecated.
      use downloadStream() instead.
      Reads the entire blob. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

      Code Samples

       ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
       client.download().subscribe(piece -> {
           try {
               downloadData.write(piece.array());
           } catch (IOException ex) {
               throw new UncheckedIOException(ex);
           }
       });
       

      For more information, see the Azure Docs

      This method will be deprecated in the future. Use downloadStream() instead.

      Returns:
      A reactive response containing the blob data.
    • downloadStream

      public Flux<ByteBuffer> downloadStream()
      Reads the entire blob. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

      Code Samples

       ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
       client.downloadStream().subscribe(piece -> {
           try {
               downloadData.write(piece.array());
           } catch (IOException ex) {
               throw new UncheckedIOException(ex);
           }
       });
       

      For more information, see the Azure Docs

      Returns:
      A reactive response containing the blob data.
    • downloadContent

      public Mono<com.azure.core.util.BinaryData> downloadContent()
      Reads the entire blob. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

      Code Samples

       client.downloadContent().subscribe(data -> {
           System.out.printf("Downloaded %s", data.toString());
       });
       

      For more information, see the Azure Docs

      This method supports downloads up to 2GB of data. Use downloadStream() to download larger blobs.

      Returns:
      A reactive response containing the blob data.
    • downloadWithResponse

      @Deprecated public Mono<BlobDownloadAsyncResponse> downloadWithResponse(BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5)
      Reads a range of bytes from a blob. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

      Code Samples

       BlobRange range = new BlobRange(1024, (long) 2048);
       DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
      
       client.downloadWithResponse(range, options, null, false).subscribe(response -> {
           ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
           response.getValue().subscribe(piece -> {
               try {
                   downloadData.write(piece.array());
               } catch (IOException ex) {
                   throw new UncheckedIOException(ex);
               }
           });
       });
       

      For more information, see the Azure Docs

      This method will be deprecated in the future. Use downloadStreamWithResponse(BlobRange, DownloadRetryOptions, BlobRequestConditions, boolean) instead.

      Parameters:
      range - BlobRange
      options - DownloadRetryOptions
      requestConditions - BlobRequestConditions
      getRangeContentMd5 - Whether the contentMD5 for the specified blob range should be returned.
      Returns:
      A reactive response containing the blob data.
    • downloadStreamWithResponse

      public Mono<BlobDownloadAsyncResponse> downloadStreamWithResponse(BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5)
      Reads a range of bytes from a blob. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

      Code Samples

       BlobRange range = new BlobRange(1024, (long) 2048);
       DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
      
       client.downloadStreamWithResponse(range, options, null, false).subscribe(response -> {
           ByteArrayOutputStream downloadData = new ByteArrayOutputStream();
           response.getValue().subscribe(piece -> {
               try {
                   downloadData.write(piece.array());
               } catch (IOException ex) {
                   throw new UncheckedIOException(ex);
               }
           });
       });
       

      For more information, see the Azure Docs

      Parameters:
      range - BlobRange
      options - DownloadRetryOptions
      requestConditions - BlobRequestConditions
      getRangeContentMd5 - Whether the contentMD5 for the specified blob range should be returned.
      Returns:
      A reactive response containing the blob data.
    • downloadContentWithResponse

      public Mono<BlobDownloadContentAsyncResponse> downloadContentWithResponse(DownloadRetryOptions options, BlobRequestConditions requestConditions)
      Reads a range of bytes from a blob. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

      Code Samples

       DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
      
       client.downloadContentWithResponse(options, null).subscribe(response -> {
           BinaryData content = response.getValue();
           System.out.println(content.toString());
       });
       

      For more information, see the Azure Docs

      This method supports downloads up to 2GB of data. Use downloadStreamWithResponse(BlobRange, DownloadRetryOptions, BlobRequestConditions, boolean) to download larger blobs.

      Parameters:
      options - DownloadRetryOptions
      requestConditions - BlobRequestConditions
      Returns:
      A reactive response containing the blob data.
    • downloadToFile

      public Mono<BlobProperties> downloadToFile(String filePath)
      Downloads the entire blob into a file specified by the path.

      The file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown.

      Code Samples

       client.downloadToFile(file).subscribe(response -> System.out.println("Completed download to file"));
       

      For more information, see the Azure Docs

      Parameters:
      filePath - A String representing the filePath where the downloaded data will be written.
      Returns:
      A reactive response containing the blob properties and metadata.
    • downloadToFile

      public Mono<BlobProperties> downloadToFile(String filePath, boolean overwrite)
      Downloads the entire blob into a file specified by the path.

      If overwrite is set to false, the file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown.

      Code Samples

       boolean overwrite = false; // Default value
       client.downloadToFile(file, overwrite).subscribe(response -> System.out.println("Completed download to file"));
       

      For more information, see the Azure Docs

      Parameters:
      filePath - A String representing the filePath where the downloaded data will be written.
      overwrite - Whether to overwrite the file, should the file exist.
      Returns:
      A reactive response containing the blob properties and metadata.
    • downloadToFileWithResponse

      public Mono<com.azure.core.http.rest.Response<BlobProperties>> downloadToFileWithResponse(String filePath, BlobRange range, ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean rangeGetContentMd5)
      Downloads the entire blob into a file specified by the path.

      The file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown.

      Code Samples

       BlobRange range = new BlobRange(1024, 2048L);
       DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
      
       client.downloadToFileWithResponse(file, range, null, options, null, false)
           .subscribe(response -> System.out.println("Completed download to file"));
       

      For more information, see the Azure Docs

      Parameters:
      filePath - A String representing the filePath where the downloaded data will be written.
      range - BlobRange
      parallelTransferOptions - ParallelTransferOptions to use to download to file. Number of parallel transfers parameter is ignored.
      options - DownloadRetryOptions
      requestConditions - BlobRequestConditions
      rangeGetContentMd5 - Whether the contentMD5 for the specified blob range should be returned.
      Returns:
      A reactive response containing the blob properties and metadata.
      Throws:
      IllegalArgumentException - If blockSize is less than 0 or greater than 4000MB.
      UncheckedIOException - If an I/O error occurs.
    • downloadToFileWithResponse

      public Mono<com.azure.core.http.rest.Response<BlobProperties>> downloadToFileWithResponse(String filePath, BlobRange range, ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Set<OpenOption> openOptions)
      Downloads the entire blob into a file specified by the path.

      By default the file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown. To override this behavior, provide appropriate OpenOptions

      Code Samples

       BlobRange blobRange = new BlobRange(1024, 2048L);
       DownloadRetryOptions downloadRetryOptions = new DownloadRetryOptions().setMaxRetryRequests(5);
       Set<OpenOption> openOptions = new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW,
           StandardOpenOption.WRITE, StandardOpenOption.READ)); // Default options
      
       client.downloadToFileWithResponse(file, blobRange, null, downloadRetryOptions, null, false, openOptions)
           .subscribe(response -> System.out.println("Completed download to file"));
       

      For more information, see the Azure Docs

      Parameters:
      filePath - A String representing the filePath where the downloaded data will be written.
      range - BlobRange
      parallelTransferOptions - ParallelTransferOptions to use to download to file. Number of parallel transfers parameter is ignored.
      options - DownloadRetryOptions
      requestConditions - BlobRequestConditions
      rangeGetContentMd5 - Whether the contentMD5 for the specified blob range should be returned.
      openOptions - OpenOptions to use to configure how to open or create the file.
      Returns:
      A reactive response containing the blob properties and metadata.
      Throws:
      IllegalArgumentException - If blockSize is less than 0 or greater than 4000MB.
      UncheckedIOException - If an I/O error occurs.
    • downloadToFileWithResponse

      public Mono<com.azure.core.http.rest.Response<BlobProperties>> downloadToFileWithResponse(BlobDownloadToFileOptions options)
      Downloads the entire blob into a file specified by the path.

      By default the file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown. To override this behavior, provide appropriate OpenOptions

      Code Samples

       client.downloadToFileWithResponse(new BlobDownloadToFileOptions(file)
           .setRange(new BlobRange(1024, 2018L))
           .setDownloadRetryOptions(new DownloadRetryOptions().setMaxRetryRequests(5))
           .setOpenOptions(new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE,
               StandardOpenOption.READ))))
           .subscribe(response -> System.out.println("Completed download to file"));
       

      For more information, see the Azure Docs

      Parameters:
      options - BlobDownloadToFileOptions
      Returns:
      A reactive response containing the blob properties and metadata.
      Throws:
      IllegalArgumentException - If blockSize is less than 0 or greater than 4000MB.
      UncheckedIOException - If an I/O error occurs.
    • delete

      public Mono<Void> delete()
      Deletes the specified blob or snapshot. To delete a blob with its snapshots use deleteIfExistsWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions) and set DeleteSnapshotsOptionType to INCLUDE.

      Code Samples

       client.delete().doOnSuccess(response -> System.out.println("Completed delete"));
       

      For more information, see the Azure Docs

      Returns:
      A reactive response signalling completion.
    • deleteWithResponse

      public Mono<com.azure.core.http.rest.Response<Void>> deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions)
      Deletes the specified blob or snapshot. To delete a blob with its snapshots set DeleteSnapshotsOptionType to INCLUDE.

      Code Samples

       client.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null)
           .subscribe(response -> System.out.printf("Delete completed with status %d%n", response.getStatusCode()));
       

      For more information, see the Azure Docs

      Parameters:
      deleteBlobSnapshotOptions - Specifies the behavior for deleting the snapshots on this blob. Include will delete the base blob and all snapshots. Only will delete only the snapshots. If a snapshot is being deleted, you must pass null.
      requestConditions - BlobRequestConditions
      Returns:
      A reactive response signalling completion.
    • deleteIfExists

      public Mono<Boolean> deleteIfExists()
      Deletes the specified blob or snapshot if it exists. To delete a blob with its snapshots use deleteWithResponse(DeleteSnapshotsOptionType, BlobRequestConditions) and set DeleteSnapshotsOptionType to INCLUDE.

      Code Samples

       client.deleteIfExists().subscribe(deleted -> {
           if (deleted) {
               System.out.println("Successfully deleted.");
           } else {
               System.out.println("Does not exist.");
           }
       });
       

      For more information, see the Azure Docs

      Returns:
      A reactive response signaling completion. true indicates that the blob was deleted. false indicates the blob does not exist at this location.
    • deleteIfExistsWithResponse

      public Mono<com.azure.core.http.rest.Response<Boolean>> deleteIfExistsWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions)
      Deletes the specified blob or snapshot if it exists. To delete a blob with its snapshots set DeleteSnapshotsOptionType to INCLUDE.

      Code Samples

       client.deleteIfExistsWithResponse(DeleteSnapshotsOptionType.INCLUDE, null).subscribe(response -> {
           if (response.getStatusCode() == 404) {
               System.out.println("Does not exist.");
           } else {
               System.out.println("successfully deleted.");
           }
       });
       

      For more information, see the Azure Docs

      Parameters:
      deleteBlobSnapshotOptions - Specifies the behavior for deleting the snapshots on this blob. Include will delete the base blob and all snapshots. Only will delete only the snapshots. If a snapshot is being deleted, you must pass null.
      requestConditions - BlobRequestConditions
      Returns:
      A reactive response signaling completion. If Response's status code is 202, the base blob was successfully deleted. If status code is 404, the base blob does not exist.
    • getProperties

      public Mono<BlobProperties> getProperties()
      Returns the blob's metadata and properties.

      Code Samples

       client.getProperties().subscribe(response ->
           System.out.printf("Type: %s, Size: %d%n", response.getBlobType(), response.getBlobSize()));
       

      For more information, see the Azure Docs

      Returns:
      A reactive response containing the blob properties and metadata.
    • getPropertiesWithResponse

      public Mono<com.azure.core.http.rest.Response<BlobProperties>> getPropertiesWithResponse(BlobRequestConditions requestConditions)
      Returns the blob's metadata and properties.

      Code Samples

       BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
      
       client.getPropertiesWithResponse(requestConditions).subscribe(
           response -> System.out.printf("Type: %s, Size: %d%n", response.getValue().getBlobType(),
               response.getValue().getBlobSize()));
       

      For more information, see the Azure Docs

      Parameters:
      requestConditions - BlobRequestConditions
      Returns:
      A reactive response containing the blob properties and metadata.
    • setHttpHeaders

      public Mono<Void> setHttpHeaders(BlobHttpHeaders headers)
      Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In order to preserve existing values, they must be passed alongside the header being changed.

      Code Samples

       client.setHttpHeaders(new BlobHttpHeaders()
           .setContentLanguage("en-US")
           .setContentType("binary"));
       

      For more information, see the Azure Docs

      Parameters:
      headers - BlobHttpHeaders
      Returns:
      A reactive response signalling completion.
    • setHttpHeadersWithResponse

      public Mono<com.azure.core.http.rest.Response<Void>> setHttpHeadersWithResponse(BlobHttpHeaders headers, BlobRequestConditions requestConditions)
      Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In order to preserve existing values, they must be passed alongside the header being changed.

      Code Samples

       BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
      
       client.setHttpHeadersWithResponse(new BlobHttpHeaders()
           .setContentLanguage("en-US")
           .setContentType("binary"), requestConditions).subscribe(
               response ->
                   System.out.printf("Set HTTP headers completed with status %d%n",
                       response.getStatusCode()));
       

      For more information, see the Azure Docs

      Parameters:
      headers - BlobHttpHeaders
      requestConditions - BlobRequestConditions
      Returns:
      A reactive response signalling completion.
    • setMetadata

      public Mono<Void> setMetadata(Map<String,String> metadata)
      Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values must be preserved, they must be downloaded and included in the call to this method.

      Code Samples

       client.setMetadata(Collections.singletonMap("metadata", "value"));
       

      For more information, see the Azure Docs

      Parameters:
      metadata - Metadata to associate with the blob. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
      Returns:
      A reactive response signalling completion.
    • setMetadataWithResponse

      public Mono<com.azure.core.http.rest.Response<Void>> setMetadataWithResponse(Map<String,String> metadata, BlobRequestConditions requestConditions)
      Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values must be preserved, they must be downloaded and included in the call to this method.

      Code Samples

       BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
      
       client.setMetadataWithResponse(Collections.singletonMap("metadata", "value"), requestConditions)
           .subscribe(response -> System.out.printf("Set metadata completed with status %d%n", response.getStatusCode()));
       

      For more information, see the Azure Docs

      Parameters:
      metadata - Metadata to associate with the blob. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
      requestConditions - BlobRequestConditions
      Returns:
      A reactive response signalling completion.
    • getTags

      public Mono<Map<String,String>> getTags()
      Returns the blob's tags.

      Code Samples

       client.getTags().subscribe(response ->
           System.out.printf("Num tags: %d%n", response.size()));
       

      For more information, see the Azure Docs

      Returns:
      A reactive response containing the blob's tags.
    • getTagsWithResponse

      public Mono<com.azure.core.http.rest.Response<Map<String,String>>> getTagsWithResponse(BlobGetTagsOptions options)
      Returns the blob's tags.

      Code Samples

       client.getTagsWithResponse(new BlobGetTagsOptions()).subscribe(response ->
           System.out.printf("Status code: %d. Num tags: %d%n", response.getStatusCode(), response.getValue().size()));
       

      For more information, see the Azure Docs

      Parameters:
      options - BlobGetTagsOptions
      Returns:
      A reactive response containing the blob's tags.
    • setTags

      public Mono<Void> setTags(Map<String,String> tags)
      Sets user defined tags. The specified tags in this method will replace existing tags. If old values must be preserved, they must be downloaded and included in the call to this method.

      Code Samples

       client.setTags(Collections.singletonMap("tag", "value"));
       

      For more information, see the Azure Docs

      Parameters:
      tags - Tags to associate with the blob.
      Returns:
      A reactive response signaling completion.
    • setTagsWithResponse

      public Mono<com.azure.core.http.rest.Response<Void>> setTagsWithResponse(BlobSetTagsOptions options)
      Sets user defined tags. The specified tags in this method will replace existing tags. If old values must be preserved, they must be downloaded and included in the call to this method.

      Code Samples

       client.setTagsWithResponse(new BlobSetTagsOptions(Collections.singletonMap("tag", "value")))
           .subscribe(response -> System.out.printf("Set tags completed with stats %d%n", response.getStatusCode()));
       

      For more information, see the Azure Docs

      Parameters:
      options - BlobSetTagsOptions
      Returns:
      A reactive response signaling completion.
    • createSnapshot

      public Mono<BlobAsyncClientBase> createSnapshot()
      Creates a read-only snapshot of the blob.

      Code Samples

       client.createSnapshot()
           .subscribe(response -> System.out.printf("Identifier for the snapshot is %s%n",
               response.getSnapshotId()));
       

      For more information, see the Azure Docs

      Returns:
      A response containing a BlobAsyncClientBase which is used to interact with the created snapshot, use getSnapshotId() to get the identifier for the snapshot.
    • createSnapshotWithResponse

      public Mono<com.azure.core.http.rest.Response<BlobAsyncClientBase>> createSnapshotWithResponse(Map<String,String> metadata, BlobRequestConditions requestConditions)
      Creates a read-only snapshot of the blob.

      Code Samples

       Map<String, String> snapshotMetadata = Collections.singletonMap("metadata", "value");
       BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
      
       client.createSnapshotWithResponse(snapshotMetadata, requestConditions)
           .subscribe(response -> System.out.printf("Identifier for the snapshot is %s%n", response.getValue()));
       

      For more information, see the Azure Docs

      Parameters:
      metadata - Metadata to associate with the resource. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
      requestConditions - BlobRequestConditions
      Returns:
      A response containing a BlobAsyncClientBase which is used to interact with the created snapshot, use getSnapshotId() to get the identifier for the snapshot.
    • setAccessTier

      public Mono<Void> setAccessTier(AccessTier tier)
      Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's etag.

      Code Samples

       client.setAccessTier(AccessTier.HOT);
       

      For more information, see the Azure Docs

      Parameters:
      tier - The new tier for the blob.
      Returns:
      A reactive response signalling completion.
      Throws:
      NullPointerException - if tier is null.
    • setAccessTierWithResponse

      public Mono<com.azure.core.http.rest.Response<Void>> setAccessTierWithResponse(AccessTier tier, RehydratePriority priority, String leaseId)
      Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's etag.

      Code Samples

       client.setAccessTierWithResponse(AccessTier.HOT, RehydratePriority.STANDARD, leaseId)
           .subscribe(response -> System.out.printf("Set tier completed with status code %d%n",
               response.getStatusCode()));
       

      For more information, see the Azure Docs

      Parameters:
      tier - The new tier for the blob.
      priority - Optional priority to set for re-hydrating blobs.
      leaseId - The lease ID the active lease on the blob must match.
      Returns:
      A reactive response signalling completion.
      Throws:
      NullPointerException - if tier is null.
    • setAccessTierWithResponse

      public Mono<com.azure.core.http.rest.Response<Void>> setAccessTierWithResponse(BlobSetAccessTierOptions options)
      Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's etag.

      Code Samples

       client.setAccessTierWithResponse(new BlobSetAccessTierOptions(AccessTier.HOT)
           .setPriority(RehydratePriority.STANDARD)
           .setLeaseId(leaseId)
           .setTagsConditions(tags))
           .subscribe(response -> System.out.printf("Set tier completed with status code %d%n",
               response.getStatusCode()));
       

      For more information, see the Azure Docs

      Parameters:
      options - BlobSetAccessTierOptions
      Returns:
      A reactive response signalling completion.
      Throws:
      NullPointerException - if tier is null.
    • undelete

      public Mono<Void> undelete()
      Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots.

      Code Samples

       client.undelete().doOnSuccess(response -> System.out.println("Completed undelete"));
       

      For more information, see the Azure Docs

      Returns:
      A reactive response signalling completion.
    • undeleteWithResponse

      public Mono<com.azure.core.http.rest.Response<Void>> undeleteWithResponse()
      Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots.

      Code Samples

       client.undeleteWithResponse()
           .subscribe(response -> System.out.printf("Undelete completed with status %d%n", response.getStatusCode()));
       

      For more information, see the Azure Docs

      Returns:
      A reactive response signalling completion.
    • getAccountInfo

      public Mono<StorageAccountInfo> getAccountInfo()
      Returns the sku name and account kind for the account.

      Code Samples

       client.getAccountInfo().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n",
           response.getAccountKind(), response.getSkuName()));
       

      For more information, see the Azure Docs

      Returns:
      a reactor response containing the sku name and account kind.
    • getAccountInfoWithResponse

      public Mono<com.azure.core.http.rest.Response<StorageAccountInfo>> getAccountInfoWithResponse()
      Returns the sku name and account kind for the account.

      Code Samples

       client.getAccountInfoWithResponse().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n",
           response.getValue().getAccountKind(), response.getValue().getSkuName()));
       

      For more information, see the Azure Docs

      Returns:
      a reactor response containing the sku name and account kind.
    • generateUserDelegationSas

      public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey)
      Generates a user delegation SAS for the blob using the specified BlobServiceSasSignatureValues.

      See BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS.

      Code Samples

       OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
       BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true);
      
       BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
           .setStartTime(OffsetDateTime.now());
      
       client.generateUserDelegationSas(values, userDelegationKey);
       
      Parameters:
      blobServiceSasSignatureValues - BlobServiceSasSignatureValues
      userDelegationKey - A UserDelegationKey object used to sign the SAS values. See BlobServiceAsyncClient.getUserDelegationKey(OffsetDateTime, OffsetDateTime) for more information on how to get a user delegation key.
      Returns:
      A String representing the SAS query parameters.
    • generateUserDelegationSas

      public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, com.azure.core.util.Context context)
      Generates a user delegation SAS for the blob using the specified BlobServiceSasSignatureValues.

      See BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS.

      Code Samples

       OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
       BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true);
      
       BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
           .setStartTime(OffsetDateTime.now());
      
       client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value"));
       
      Parameters:
      blobServiceSasSignatureValues - BlobServiceSasSignatureValues
      userDelegationKey - A UserDelegationKey object used to sign the SAS values. See BlobServiceAsyncClient.getUserDelegationKey(OffsetDateTime, OffsetDateTime) for more information on how to get a user delegation key.
      accountName - The account name.
      context - Additional context that is passed through the code when generating a SAS.
      Returns:
      A String representing the SAS query parameters.
    • generateSas

      public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues)
      Generates a service SAS for the blob using the specified BlobServiceSasSignatureValues

      Note : The client must be authenticated via StorageSharedKeyCredential

      See BlobServiceSasSignatureValues for more information on how to construct a service SAS.

      Code Samples

       OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
       BlobSasPermission permission = new BlobSasPermission().setReadPermission(true);
      
       BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
           .setStartTime(OffsetDateTime.now());
      
       client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
       
      Parameters:
      blobServiceSasSignatureValues - BlobServiceSasSignatureValues
      Returns:
      A String representing the SAS query parameters.
    • generateSas

      public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, com.azure.core.util.Context context)
      Generates a service SAS for the blob using the specified BlobServiceSasSignatureValues

      Note : The client must be authenticated via StorageSharedKeyCredential

      See BlobServiceSasSignatureValues for more information on how to construct a service SAS.

      Code Samples

       OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
       BlobSasPermission permission = new BlobSasPermission().setReadPermission(true);
      
       BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
           .setStartTime(OffsetDateTime.now());
      
       // Client must be authenticated via StorageSharedKeyCredential
       client.generateSas(values, new Context("key", "value"));
       
      Parameters:
      blobServiceSasSignatureValues - BlobServiceSasSignatureValues
      context - Additional context that is passed through the code when generating a SAS.
      Returns:
      A String representing the SAS query parameters.
    • query

      public Flux<ByteBuffer> query(String expression)
      Queries the entire blob.

      For more information, see the Azure Docs

      Code Samples

       ByteArrayOutputStream queryData = new ByteArrayOutputStream();
       String expression = "SELECT * from BlobStorage";
       client.query(expression).subscribe(piece -> {
           try {
               queryData.write(piece.array());
           } catch (IOException ex) {
               throw new UncheckedIOException(ex);
           }
       });
       
      Parameters:
      expression - The query expression.
      Returns:
      A reactive response containing the queried data.
    • queryWithResponse

      public Mono<BlobQueryAsyncResponse> queryWithResponse(BlobQueryOptions queryOptions)
      Queries the entire blob.

      For more information, see the Azure Docs

      Code Samples

       String expression = "SELECT * from BlobStorage";
       BlobQueryJsonSerialization input = new BlobQueryJsonSerialization()
           .setRecordSeparator('\n');
       BlobQueryDelimitedSerialization output = new BlobQueryDelimitedSerialization()
           .setEscapeChar('\0')
           .setColumnSeparator(',')
           .setRecordSeparator('\n')
           .setFieldQuote('\'')
           .setHeadersPresent(true);
       BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
       Consumer<BlobQueryError> errorConsumer = System.out::println;
       Consumer<BlobQueryProgress> progressConsumer = progress -> System.out.println("total blob bytes read: "
           + progress.getBytesScanned());
       BlobQueryOptions queryOptions = new BlobQueryOptions(expression)
           .setInputSerialization(input)
           .setOutputSerialization(output)
           .setRequestConditions(requestConditions)
           .setErrorConsumer(errorConsumer)
           .setProgressConsumer(progressConsumer);
      
       client.queryWithResponse(queryOptions)
           .subscribe(response -> {
               ByteArrayOutputStream queryData = new ByteArrayOutputStream();
               response.getValue().subscribe(piece -> {
                   try {
                       queryData.write(piece.array());
                   } catch (IOException ex) {
                       throw new UncheckedIOException(ex);
                   }
               });
           });
       
      Parameters:
      queryOptions - The query options.
      Returns:
      A reactive response containing the queried data.
    • setImmutabilityPolicy

      public Mono<BlobImmutabilityPolicy> setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy)
      Sets the immutability policy on a blob, blob snapshot or blob version.

      NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with object level immutable policy enabled to call this API.

      Code Samples

       BlobImmutabilityPolicy policy = new BlobImmutabilityPolicy()
           .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED)
           .setExpiryTime(OffsetDateTime.now().plusDays(1));
       client.setImmutabilityPolicy(policy).subscribe(response -> System.out.println("Completed. Set immutability "
           + "policy to " + response.getPolicyMode()));
       
      Parameters:
      immutabilityPolicy - The immutability policy.
      Returns:
      A reactive response containing the immutability policy.
    • setImmutabilityPolicyWithResponse

      public Mono<com.azure.core.http.rest.Response<BlobImmutabilityPolicy>> setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy immutabilityPolicy, BlobRequestConditions requestConditions)
      Sets the immutability policy on a blob, blob snapshot or blob version.

      NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with immutable storage with versioning enabled to call this API.

      Code Samples

       BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy()
           .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED)
           .setExpiryTime(OffsetDateTime.now().plusDays(1));
       BlobRequestConditions requestConditions = new BlobRequestConditions()
           .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1));
       client.setImmutabilityPolicyWithResponse(immutabilityPolicy, requestConditions).subscribe(response ->
           System.out.println("Completed. Set immutability policy to " + response.getValue().getPolicyMode()));
       
      Parameters:
      immutabilityPolicy - The immutability policy.
      requestConditions - BlobRequestConditions
      Returns:
      A reactive response containing the immutability policy.
    • deleteImmutabilityPolicy

      public Mono<Void> deleteImmutabilityPolicy()
      Deletes the immutability policy on a blob, blob snapshot or blob version.

      NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with object level immutable policy enabled to call this API.

      Code Samples

       client.deleteImmutabilityPolicy().subscribe(response -> System.out.println("Completed immutability policy"
           + " deletion."));
       
      Returns:
      A reactive response signalling completion.
    • deleteImmutabilityPolicyWithResponse

      public Mono<com.azure.core.http.rest.Response<Void>> deleteImmutabilityPolicyWithResponse()
      Deletes the immutability policy on a blob, blob snapshot or blob version.

      NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with immutable storage with versioning enabled to call this API.

      Code Samples

       client.deleteImmutabilityPolicyWithResponse().subscribe(response ->
           System.out.println("Delete immutability policy completed with status: " + response.getStatusCode()));
       
      Returns:
      A reactive response signalling completion.
    • setLegalHold

      public Mono<BlobLegalHoldResult> setLegalHold(boolean legalHold)
      Sets a legal hold on the blob.

      NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with object level immutable policy enabled to call this API.

      Code Samples

       client.setLegalHold(true).subscribe(response -> System.out.println("Legal hold status: "
           + response.hasLegalHold()));
       
      Parameters:
      legalHold - Whether you want a legal hold on the blob.
      Returns:
      A reactive response containing the legal hold result.
    • setLegalHoldWithResponse

      public Mono<com.azure.core.http.rest.Response<BlobLegalHoldResult>> setLegalHoldWithResponse(boolean legalHold)
      Sets a legal hold on the blob.

      NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with immutable storage with versioning enabled to call this API.

      Code Samples

       client.setLegalHoldWithResponse(true).subscribe(response ->
           System.out.println("Legal hold status: " + response.getValue().hasLegalHold()));
       
      Parameters:
      legalHold - Whether you want a legal hold on the blob.
      Returns:
      A reactive response containing the legal hold result.