public final class BlobServiceAsyncClient extends Object
BlobServiceClientBuilder. This class does
not hold any state about a particular storage account but is instead a convenient way of sending off appropriate
requests to the resource on the service. It may also be used to construct URLs to blobs and containers.
This client contains operations on a blob. Operations on a container are available on BlobContainerAsyncClient through BlobServiceAsyncClient.getBlobContainerAsyncClient(String), and operations on a blob are
available on BlobAsyncClient.
Please see here for more information on containers.
Note this client is an async client that returns reactive responses from Spring Reactor Core project
(https://projectreactor.io/). Calling the methods in this client will NOT start the actual network
operation, until .subscribe() is called on the reactive response. You can simply convert one of these
responses to a CompletableFuture object through Mono.toFuture().
| Modifier and Type | Method and Description |
|---|---|
Mono<BlobContainerAsyncClient> |
createBlobContainer(String containerName)
Creates a new container within a storage account.
|
Mono<com.azure.core.http.rest.Response<BlobContainerAsyncClient>> |
createBlobContainerWithResponse(String containerName,
Map<String,String> metadata,
PublicAccessType accessType)
Creates a new container within a storage account.
|
Mono<Void> |
deleteBlobContainer(String containerName)
Deletes the specified container in the storage account.
|
Mono<com.azure.core.http.rest.Response<Void>> |
deleteBlobContainerWithResponse(String containerName)
Deletes the specified container in the storage account.
|
String |
generateAccountSas(AccountSasSignatureValues accountSasSignatureValues)
Generates an account SAS for the Azure Storage account using the specified
AccountSasSignatureValues. |
Mono<StorageAccountInfo> |
getAccountInfo()
Returns the sku name and account kind for the account.
|
Mono<com.azure.core.http.rest.Response<StorageAccountInfo>> |
getAccountInfoWithResponse()
Returns the sku name and account kind for the account.
|
String |
getAccountName()
Get associated account name.
|
String |
getAccountUrl()
Gets the URL of the storage account represented by this client.
|
BlobContainerAsyncClient |
getBlobContainerAsyncClient(String containerName)
Initializes a
BlobContainerAsyncClient object pointing to the specified container. |
com.azure.core.http.HttpPipeline |
getHttpPipeline()
Gets the
HttpPipeline powering this client. |
Mono<BlobServiceProperties> |
getProperties()
Gets the properties of a storage account’s Blob service.
|
Mono<com.azure.core.http.rest.Response<BlobServiceProperties>> |
getPropertiesWithResponse()
Gets the properties of a storage account’s Blob service.
|
BlobServiceVersion |
getServiceVersion()
Gets the service version the client is using.
|
Mono<BlobServiceStatistics> |
getStatistics()
Retrieves statistics related to replication for the Blob service.
|
Mono<com.azure.core.http.rest.Response<BlobServiceStatistics>> |
getStatisticsWithResponse()
Retrieves statistics related to replication for the Blob service.
|
Mono<UserDelegationKey> |
getUserDelegationKey(OffsetDateTime start,
OffsetDateTime expiry)
Gets a user delegation key for use with this account's blob storage.
|
Mono<com.azure.core.http.rest.Response<UserDelegationKey>> |
getUserDelegationKeyWithResponse(OffsetDateTime start,
OffsetDateTime expiry)
Gets a user delegation key for use with this account's blob storage.
|
com.azure.core.http.rest.PagedFlux<BlobContainerItem> |
listBlobContainers()
Returns a reactive Publisher emitting all the containers in this account lazily as needed.
|
com.azure.core.http.rest.PagedFlux<BlobContainerItem> |
listBlobContainers(ListBlobContainersOptions options)
Returns a reactive Publisher emitting all the containers in this account lazily as needed.
|
Mono<Void> |
setProperties(BlobServiceProperties properties)
Sets properties for a storage account's Blob service endpoint.
|
Mono<com.azure.core.http.rest.Response<Void>> |
setPropertiesWithResponse(BlobServiceProperties properties)
Sets properties for a storage account's Blob service endpoint.
|
public BlobContainerAsyncClient getBlobContainerAsyncClient(String containerName)
BlobContainerAsyncClient object pointing to the specified container. This method does not
create a container. It simply constructs the URL to the container and offers access to methods relevant to
containers.
Code Samples
BlobContainerAsyncClient blobContainerAsyncClient = client.getBlobContainerAsyncClient("containerName");
containerName - The name of the container to point to. A value of null or empty string will be interpreted
as pointing to the root container and will be replaced by "$root".BlobContainerAsyncClient object pointing to the specified containerpublic com.azure.core.http.HttpPipeline getHttpPipeline()
HttpPipeline powering this client.public BlobServiceVersion getServiceVersion()
public Mono<BlobContainerAsyncClient> createBlobContainer(String containerName)
Code Samples
BlobContainerAsyncClient blobContainerAsyncClient =
client.createBlobContainer("containerName").block();
containerName - Name of the container to createMono containing a BlobContainerAsyncClient used to interact with the container created.public Mono<com.azure.core.http.rest.Response<BlobContainerAsyncClient>> createBlobContainerWithResponse(String containerName, Map<String,String> metadata, PublicAccessType accessType)
Code Samples
Map<String,String> metadata =Collections.singletonMap("metadata", "value");BlobContainerAsyncClientcontainerClient = client .createBlobContainerWithResponse("containerName", metadata,PublicAccessType.CONTAINER).block().getValue();
containerName - Name of the container to createmetadata - Metadata to associate with the containeraccessType - Specifies how the data in this container is available to the public. See the
x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.Mono containing a Response whose value contains a BlobContainerAsyncClient used to interact with the container created.public Mono<Void> deleteBlobContainer(String containerName)
Code Samples
client.deleteBlobContainer("containerName").subscribe(
response -> System.out.printf("Delete container completed%n"),
error -> System.out.printf("Delete container failed: %s%n", error));
containerName - Name of the container to deleteMono containing containing status code and HTTP headerspublic Mono<com.azure.core.http.rest.Response<Void>> deleteBlobContainerWithResponse(String containerName)
Code Samples
Contextcontext = newContext("Key", "Value"); client.deleteBlobContainerWithResponse("containerName").subscribe(response ->System.out.printf("Delete container completed with status %d%n", response.getStatusCode()));
containerName - Name of the container to deleteMono containing containing status code and HTTP headerspublic String getAccountUrl()
public com.azure.core.http.rest.PagedFlux<BlobContainerItem> listBlobContainers()
Code Samples
client.listBlobContainers().subscribe(container -> System.out.printf("Name: %s%n", container.getName()));
public com.azure.core.http.rest.PagedFlux<BlobContainerItem> listBlobContainers(ListBlobContainersOptions options)
Code Samples
ListBlobContainersOptionsoptions = newListBlobContainersOptions() .setPrefix("containerNamePrefixToMatch") .setDetails(newBlobContainerListDetails().setRetrieveMetadata(true)); client.listBlobContainers(options).subscribe(container ->System.out.printf("Name: %s%n", container.getName()));
options - A ListBlobContainersOptions which specifies what data should be returned by the service.public Mono<BlobServiceProperties> getProperties()
Code Samples
client.getProperties().subscribe(response ->
System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n",
response.getHourMetrics().isEnabled(),
response.getMinuteMetrics().isEnabled()));
public Mono<com.azure.core.http.rest.Response<BlobServiceProperties>> getPropertiesWithResponse()
Code Samples
client.getPropertiesWithResponse().subscribe(response ->
System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b%n",
response.getValue().getHourMetrics().isEnabled(),
response.getValue().getMinuteMetrics().isEnabled()));
Mono containing a Response whose value contains the storage
account properties.public Mono<Void> setProperties(BlobServiceProperties properties)
Code Samples
BlobRetentionPolicyloggingRetentionPolicy = newBlobRetentionPolicy().setEnabled(true).setDays(3);BlobRetentionPolicymetricsRetentionPolicy = newBlobRetentionPolicy().setEnabled(true).setDays(1);BlobServicePropertiesproperties = newBlobServiceProperties() .setLogging(newBlobAnalyticsLogging() .setWrite(true) .setDelete(true) .setRetentionPolicy(loggingRetentionPolicy)) .setHourMetrics(newBlobMetrics() .setEnabled(true) .setRetentionPolicy(metricsRetentionPolicy)) .setMinuteMetrics(newBlobMetrics() .setEnabled(true) .setRetentionPolicy(metricsRetentionPolicy)); client.setProperties(properties).subscribe( response ->System.out.printf("Setting properties completed%n"), error ->System.out.printf("Setting properties failed: %s%n", error));
properties - Configures the service.Mono containing the storage account properties.public Mono<com.azure.core.http.rest.Response<Void>> setPropertiesWithResponse(BlobServiceProperties properties)
Code Samples
BlobRetentionPolicyloggingRetentionPolicy = newBlobRetentionPolicy().setEnabled(true).setDays(3);BlobRetentionPolicymetricsRetentionPolicy = newBlobRetentionPolicy().setEnabled(true).setDays(1);BlobServicePropertiesproperties = newBlobServiceProperties() .setLogging(newBlobAnalyticsLogging() .setWrite(true) .setDelete(true) .setRetentionPolicy(loggingRetentionPolicy)) .setHourMetrics(newBlobMetrics() .setEnabled(true) .setRetentionPolicy(metricsRetentionPolicy)) .setMinuteMetrics(newBlobMetrics() .setEnabled(true) .setRetentionPolicy(metricsRetentionPolicy)); client.setPropertiesWithResponse(properties).subscribe(response ->System.out.printf("Setting properties completed with status %d%n", response.getStatusCode()));
properties - Configures the service.Mono containing the storage account properties.public Mono<UserDelegationKey> getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry)
TokenCredential in this object's HttpPipeline.
Code Samples
client.getUserDelegationKey(delegationKeyStartTime, delegationKeyExpiryTime).subscribe(response ->
System.out.printf("User delegation key: %s%n", response.getValue()));
start - Start time for the key's validity. Null indicates immediate start.expiry - Expiration of the key's validity.Mono containing the user delegation key.IllegalArgumentException - If start isn't null and is after expiry.NullPointerException - If expiry is null.public Mono<com.azure.core.http.rest.Response<UserDelegationKey>> getUserDelegationKeyWithResponse(OffsetDateTime start, OffsetDateTime expiry)
TokenCredential in this object's HttpPipeline.
Code Samples
client.getUserDelegationKeyWithResponse(delegationKeyStartTime, delegationKeyExpiryTime).subscribe(response ->
System.out.printf("User delegation key: %s%n", response.getValue().getValue()));
start - Start time for the key's validity. Null indicates immediate start.expiry - Expiration of the key's validity.Mono containing a Response whose value containing the user
delegation key.IllegalArgumentException - If start isn't null and is after expiry.NullPointerException - If expiry is null.public Mono<BlobServiceStatistics> getStatistics()
Code Samples
client.getStatistics().subscribe(response ->
System.out.printf("Geo-replication status: %s%n", response.getGeoReplication().getStatus()));
Mono containing the storage account statistics.public Mono<com.azure.core.http.rest.Response<BlobServiceStatistics>> getStatisticsWithResponse()
Code Samples
client.getStatisticsWithResponse().subscribe(response ->
System.out.printf("Geo-replication status: %s%n", response.getValue().getGeoReplication().getStatus()));
Mono containing a Response whose value containing the
storage account statistics.public Mono<StorageAccountInfo> getAccountInfo()
Code Samples
client.getAccountInfo().subscribe(response ->
System.out.printf("Account kind: %s, SKU: %s%n", response.getAccountKind(), response.getSkuName()));
Mono containing containing the storage account info.public Mono<com.azure.core.http.rest.Response<StorageAccountInfo>> getAccountInfoWithResponse()
Code Samples
client.getAccountInfoWithResponse().subscribe(response ->
System.out.printf("Account kind: %s, SKU: %s%n", response.getValue().getAccountKind(),
response.getValue().getSkuName()));
Mono containing a Response whose value the storage account
info.public String getAccountName()
public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues)
AccountSasSignatureValues.
Note : The client must be authenticated via StorageSharedKeyCredential
See AccountSasSignatureValues for more information on how to construct an account SAS.
The snippet below generates a SAS that lasts for two days and gives the user read and list access to blob containers and file shares.
AccountSasPermissionpermissions = newAccountSasPermission() .setListPermission(true) .setReadPermission(true);AccountSasResourceTyperesourceTypes = newAccountSasResourceType().setContainer(true);AccountSasServiceservices = newAccountSasService().setBlobAccess(true).setFileAccess(true);OffsetDateTimeexpiryTime =OffsetDateTime.now().plus(Duration.ofDays(2));AccountSasSignatureValuessasValues = newAccountSasSignatureValues(expiryTime, permissions, services, resourceTypes); // Client must be authenticated via StorageSharedKeyCredentialStringsas = client.generateAccountSas(sasValues);
accountSasSignatureValues - AccountSasSignatureValuesString representing all SAS query parameters.Copyright © 2020 Microsoft Corporation. All rights reserved.