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<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<Response<Void>> |
deleteBlobContainerWithResponse(String containerName)
Deletes the specified container in the storage account.
|
Mono<StorageAccountInfo> |
getAccountInfo()
Returns the sku name and account kind for the account.
|
Mono<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. |
HttpPipeline |
getHttpPipeline()
Gets the
HttpPipeline powering this client. |
Mono<BlobServiceProperties> |
getProperties()
Gets the properties of a storage account’s Blob service.
|
Mono<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<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<Response<UserDelegationKey>> |
getUserDelegationKeyWithResponse(OffsetDateTime start,
OffsetDateTime expiry)
Gets a user delegation key for use with this account's blob storage.
|
PagedFlux<BlobContainerItem> |
listBlobContainers()
Returns a reactive Publisher emitting all the containers in this account lazily as needed.
|
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<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 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<Response<BlobContainerAsyncClient>> createBlobContainerWithResponse(String containerName, Map<String,String> metadata, PublicAccessType accessType)
Code Samples
Map
<String
,String
> metadata =Collections
.singletonMap("metadata", "value");BlobContainerAsyncClient
containerClient = 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<Response<Void>> deleteBlobContainerWithResponse(String containerName)
Code Samples
Context
context = 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 PagedFlux<BlobContainerItem> listBlobContainers()
Code Samples
client.listBlobContainers().subscribe(container -> System
.out.printf("Name: %s%n", container.getName()));
public PagedFlux<BlobContainerItem> listBlobContainers(ListBlobContainersOptions options)
Code Samples
ListBlobContainersOptions
options = 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<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()));
public Mono<Void> setProperties(BlobServiceProperties properties)
Code Samples
BlobRetentionPolicy
loggingRetentionPolicy = newBlobRetentionPolicy
().setEnabled(true).setDays(3);BlobRetentionPolicy
metricsRetentionPolicy = newBlobRetentionPolicy
().setEnabled(true).setDays(1);BlobServiceProperties
properties = 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<Response<Void>> setPropertiesWithResponse(BlobServiceProperties properties)
Code Samples
BlobRetentionPolicy
loggingRetentionPolicy = newBlobRetentionPolicy
().setEnabled(true).setDays(3);BlobRetentionPolicy
metricsRetentionPolicy = newBlobRetentionPolicy
().setEnabled(true).setDays(1);BlobServiceProperties
properties = 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<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<Response<BlobServiceStatistics>> getStatisticsWithResponse()
Code Samples
client.getStatisticsWithResponse().subscribe(response ->
System
.out.printf("Geo-replication status: %s%n", response.getValue().getGeoReplication().getStatus()));
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<Response<StorageAccountInfo>> getAccountInfoWithResponse()
Code Samples
client.getAccountInfoWithResponse().subscribe(response ->
System
.out.printf("Account kind: %s, SKU: %s%n", response.getValue().getAccountKind(),
response.getValue().getSkuName()));
public String getAccountName()
Copyright © 2019 Microsoft Corporation. All rights reserved.