Class BlobContainerAsyncClient
BlobContainerClientBuilder
or via the method
BlobServiceAsyncClient.getBlobContainerAsyncClient(String)
. This class does not hold any state about a
particular blob 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.
This client contains operations on a container. Operations on a blob are available on BlobAsyncClient
through
getBlobAsyncClient(String)
, and operations on the service are available on BlobServiceAsyncClient
.
Please refer to the Azure Docs 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()
.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Special container name for the logs container in the Storage account.static final String
Special container name for the root container in the Storage account.static final String
Special container name for the static website container in the Storage account. -
Method Summary
Modifier and TypeMethodDescriptioncreate()
Creates a new container within a storage account.Creates a new container within a storage account if it does not exist.Creates a new container within a storage account if it does not exist.createWithResponse
(Map<String, String> metadata, PublicAccessType accessType) Creates a new container within a storage account.delete()
Marks the specified container for deletion.Marks the specified container for deletion if it exists.deleteIfExistsWithResponse
(BlobRequestConditions requestConditions) Marks the specified container for deletion if it exists.deleteWithResponse
(BlobRequestConditions requestConditions) Marks the specified container for deletion.exists()
Gets if the container this client represents exists in the cloud.Gets if the container this client represents exists in the cloud.com.azure.core.http.rest.PagedFlux<TaggedBlobItem>
findBlobsByTags
(FindBlobsOptions options) Returns a reactive Publisher emitting the blobs in this container whose tags match the query expression.com.azure.core.http.rest.PagedFlux<TaggedBlobItem>
findBlobsByTags
(String query) Returns a reactive Publisher emitting the blobs in this container whose tags match the query expression.generateSas
(BlobServiceSasSignatureValues blobServiceSasSignatureValues) Generates a service SAS for the container using the specifiedBlobServiceSasSignatureValues
generateSas
(BlobServiceSasSignatureValues blobServiceSasSignatureValues, com.azure.core.util.Context context) Generates a service SAS for the container using the specifiedBlobServiceSasSignatureValues
generateUserDelegationSas
(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey) Generates a user delegation SAS for the container using the specifiedBlobServiceSasSignatureValues
.generateUserDelegationSas
(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, com.azure.core.util.Context context) Generates a user delegation SAS for the container using the specifiedBlobServiceSasSignatureValues
.Returns the container's permissions.Mono<com.azure.core.http.rest.Response<BlobContainerAccessPolicies>>
getAccessPolicyWithResponse
(String leaseId) Returns the container's permissions.Returns the sku name and account kind for the account.Mono<com.azure.core.http.rest.Response<StorageAccountInfo>>
Returns the sku name and account kind for the account.Get associated account name.Get the url of the storage account.getBlobAsyncClient
(String blobName) Creates a new BlobAsyncClient object by concatenating blobName to the end of ContainerAsyncClient's URL.getBlobAsyncClient
(String blobName, String snapshot) Creates a new BlobAsyncClient object by concatenating blobName to the end of ContainerAsyncClient's URL.Get the container name.Gets the URL of the container represented by this client.getBlobVersionAsyncClient
(String blobName, String versionId) Creates a new BlobAsyncClient object by concatenating blobName to the end of ContainerAsyncClient's URL.Gets theCpkInfo
associated with this client that will be passed toBlobAsyncClients
whengetBlobAsyncClient
is called.Gets theEncryptionScope
used to encrypt this blob's content on the server.com.azure.core.http.HttpPipeline
Gets theHttpPipeline
powering this client.Returns the container's metadata and system properties.Mono<com.azure.core.http.rest.Response<BlobContainerProperties>>
getPropertiesWithResponse
(String leaseId) Returns the container's metadata and system properties.Get an async client pointing to the account.Gets the service version the client is using.com.azure.core.http.rest.PagedFlux<BlobItem>
Returns a reactive Publisher emitting all the blobs in this container lazily as needed.com.azure.core.http.rest.PagedFlux<BlobItem>
listBlobs
(ListBlobsOptions options) Returns a reactive Publisher emitting all the blobs in this container lazily as needed.com.azure.core.http.rest.PagedFlux<BlobItem>
listBlobs
(ListBlobsOptions options, String continuationToken) Returns a reactive Publisher emitting all the blobs in this container lazily as needed.com.azure.core.http.rest.PagedFlux<BlobItem>
listBlobsByHierarchy
(String directory) Returns a reactive Publisher emitting all the blobs and directories (prefixes) under the given directory (prefix).com.azure.core.http.rest.PagedFlux<BlobItem>
listBlobsByHierarchy
(String delimiter, ListBlobsOptions options) Returns a reactive Publisher emitting all the blobs and prefixes (directories) under the given prefix (directory).setAccessPolicy
(PublicAccessType accessType, List<BlobSignedIdentifier> identifiers) Sets the container's permissions.setAccessPolicyWithResponse
(PublicAccessType accessType, List<BlobSignedIdentifier> identifiers, BlobRequestConditions requestConditions) Sets the container's permissions.setMetadata
(Map<String, String> metadata) Sets the container's metadata.setMetadataWithResponse
(Map<String, String> metadata, BlobRequestConditions requestConditions) Sets the container's metadata.
-
Field Details
-
ROOT_CONTAINER_NAME
Special container name for the root container in the Storage account.- See Also:
-
STATIC_WEBSITE_CONTAINER_NAME
Special container name for the static website container in the Storage account.- See Also:
-
LOG_CONTAINER_NAME
Special container name for the logs container in the Storage account.- See Also:
-
-
Method Details
-
getBlobAsyncClient
Creates a new BlobAsyncClient object by concatenating blobName to the end of ContainerAsyncClient's URL. The new BlobAsyncClient uses the same request policy pipeline as the ContainerAsyncClient.Code Samples
BlobAsyncClient blobAsyncClient = client.getBlobAsyncClient(blobName);
- Parameters:
blobName
- AString
representing the name of the blob. If the blob name contains special characters, pass in the url encoded version of the blob name.- Returns:
- A new
BlobAsyncClient
object which references the blob with the specified name in this container.
-
getBlobAsyncClient
Creates a new BlobAsyncClient object by concatenating blobName to the end of ContainerAsyncClient's URL. The new BlobAsyncClient uses the same request policy pipeline as the ContainerAsyncClient.Code Samples
BlobAsyncClient blobAsyncClient = client.getBlobAsyncClient(blobName, snapshot);
- Parameters:
blobName
- AString
representing the name of the blob. If the blob name contains special characters, pass in the url encoded version of the blob name.snapshot
- the snapshot identifier for the blob.- Returns:
- A new
BlobAsyncClient
object which references the blob with the specified name in this container.
-
getBlobVersionAsyncClient
Creates a new BlobAsyncClient object by concatenating blobName to the end of ContainerAsyncClient's URL. The new BlobAsyncClient uses the same request policy pipeline as the ContainerAsyncClient.- Parameters:
blobName
- AString
representing the name of the blob. If the blob name contains special characters, pass in the url encoded version of the blob name.versionId
- the version identifier for the blob, passnull
to interact with the latest blob version.- Returns:
- A new
BlobAsyncClient
object which references the blob with the specified name in this container.
-
getAccountUrl
Get the url of the storage account.- Returns:
- the URL of the storage account
-
getBlobContainerUrl
Gets the URL of the container represented by this client.- Returns:
- the URL.
-
getBlobContainerName
Get the container name.Code Samples
String containerName = client.getBlobContainerName(); System.out.println("The name of the blob is " + containerName);
- Returns:
- The name of container.
-
getAccountName
Get associated account name.- Returns:
- account name associated with this storage resource.
-
getServiceAsyncClient
Get an async client pointing to the account.- Returns:
BlobServiceAsyncClient
-
getServiceVersion
Gets the service version the client is using.- Returns:
- the service version the client is using.
-
getHttpPipeline
public com.azure.core.http.HttpPipeline getHttpPipeline()Gets theHttpPipeline
powering this client.- Returns:
- The pipeline.
-
getCustomerProvidedKey
Gets theCpkInfo
associated with this client that will be passed toBlobAsyncClients
whengetBlobAsyncClient
is called.- Returns:
- the customer provided key used for encryption.
-
getEncryptionScope
Gets theEncryptionScope
used to encrypt this blob's content on the server.- Returns:
- the encryption scope used for encryption.
-
exists
Gets if the container this client represents exists in the cloud.Code Samples
client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
- Returns:
- true if the container exists, false if it doesn't
-
existsWithResponse
Gets if the container 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 container exists, false if it doesn't
-
create
Creates a new container within a storage account. If a container with the same name already exists, the operation fails. For more information, see the Azure Docs.Code Samples
client.create().subscribe( response -> System.out.printf("Create completed%n"), error -> System.out.printf("Error while creating container %s%n", error));
- Returns:
- A reactive response signalling completion.
-
createWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> createWithResponse(Map<String, String> metadata, PublicAccessType accessType) Creates a new container within a storage account. If a container with the same name already exists, the operation fails. For more information, see the Azure Docs.Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); client.createWithResponse(metadata, PublicAccessType.CONTAINER).subscribe(response -> System.out.printf("Create completed with status %d%n", response.getStatusCode()));
- Parameters:
metadata
- Metadata to associate with the container. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.accessType
- 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.- Returns:
- A reactive response signalling completion.
-
createIfNotExists
Creates a new container within a storage account if it does not exist. For more information, see the Azure Docs.Code Samples
client.createIfNotExists().subscribe(created -> { if (created) { System.out.println("successfully created."); } else { System.out.println("Already exists."); } });
- Returns:
- A reactive response signaling completion.
true
indicates a new container was created,true
indicates a container already existed at this location.
-
createIfNotExistsWithResponse
public Mono<com.azure.core.http.rest.Response<Boolean>> createIfNotExistsWithResponse(BlobContainerCreateOptions options) Creates a new container within a storage account if it does not exist. For more information, see the Azure Docs.Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); BlobContainerCreateOptions options = new BlobContainerCreateOptions().setMetadata(metadata) .setPublicAccessType(PublicAccessType.CONTAINER); client.createIfNotExistsWithResponse(options).subscribe(response -> { if (response.getStatusCode() == 409) { System.out.println("Already exists."); } else { System.out.println("successfully created."); } });
- Parameters:
options
-BlobContainerCreateOptions
- Returns:
- A reactive response signaling completion. If
Response
's status code is 201, a new container was successfully created. If status code is 409, a container already existed at this location.
-
delete
Marks the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection. For more information, see the Azure Docs.Code Samples
client.delete().subscribe( response -> System.out.printf("Delete completed%n"), error -> System.out.printf("Delete failed: %s%n", error));
- Returns:
- A reactive response signalling completion.
-
deleteWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> deleteWithResponse(BlobRequestConditions requestConditions) Marks the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection. For more information, see the Azure Docs.Code Samples
BlobRequestConditions requestConditions = new BlobRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.deleteWithResponse(requestConditions).subscribe(response -> System.out.printf("Delete completed with status %d%n", response.getStatusCode()));
- Parameters:
requestConditions
-BlobRequestConditions
- Returns:
- A reactive response signalling completion.
- Throws:
UnsupportedOperationException
- If eitherMatchConditions.getIfMatch()
orMatchConditions.getIfNoneMatch()
is set.
-
deleteIfExists
Marks the specified container for deletion if it exists. The container and any blobs contained within it are later deleted during garbage collection. For more information, see the Azure Docs.Code Samples
client.deleteIfExists().subscribe(deleted -> { if (deleted) { System.out.println("Successfully deleted."); } else { System.out.println("Does not exist."); } });
- Returns:
- A reactive response signaling completion.
true
indicates the container was deleted,false
indicates the container does not exist.
-
deleteIfExistsWithResponse
public Mono<com.azure.core.http.rest.Response<Boolean>> deleteIfExistsWithResponse(BlobRequestConditions requestConditions) Marks the specified container for deletion if it exists. The container and any blobs contained within it are later deleted during garbage collection. For more information, see the Azure Docs.Code Samples
BlobRequestConditions requestConditions = new BlobRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.deleteIfExistsWithResponse(requestConditions).subscribe(response -> { if (response.getStatusCode() == 404) { System.out.println("Does not exist."); } else { System.out.println("successfully deleted."); } });
- Parameters:
requestConditions
-BlobRequestConditions
- Returns:
- A reactive response signaling completion. If
Response
's status code is 202, the container was successfully deleted. If status code is 404, the container does not exist. - Throws:
UnsupportedOperationException
- If eitherMatchConditions.getIfMatch()
orMatchConditions.getIfNoneMatch()
is set.
-
getProperties
Returns the container's metadata and system properties. For more information, see the Azure Docs.Code Samples
client.getProperties().subscribe(response -> System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", response.getBlobPublicAccess(), response.hasLegalHold(), response.hasImmutabilityPolicy()));
- Returns:
- A
Mono
containing aResponse
whosevalue
containing the container properties.
-
getPropertiesWithResponse
public Mono<com.azure.core.http.rest.Response<BlobContainerProperties>> getPropertiesWithResponse(String leaseId) Returns the container's metadata and system properties. For more information, see the Azure Docs.Code Samples
client.getPropertiesWithResponse(leaseId).subscribe(response -> System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", response.getValue().getBlobPublicAccess(), response.getValue().hasLegalHold(), response.getValue().hasImmutabilityPolicy()));
- Parameters:
leaseId
- The lease ID the active lease on the container must match.- Returns:
- A reactive response containing the container properties.
-
setMetadata
Sets the container's metadata. For more information, see the Azure Docs.Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); client.setMetadata(metadata).subscribe( response -> System.out.printf("Set metadata completed%n"), error -> System.out.printf("Set metadata failed: %s%n", error));
- Parameters:
metadata
- Metadata to associate with the container. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.- Returns:
- A
Mono
containing aResponse
whosevalue
contains signalling completion.
-
setMetadataWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> setMetadataWithResponse(Map<String, String> metadata, BlobRequestConditions requestConditions) Sets the container's metadata. For more information, see the Azure Docs.Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); BlobRequestConditions requestConditions = new BlobRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.setMetadataWithResponse(metadata, requestConditions).subscribe(response -> System.out.printf("Set metadata completed with status %d%n", response.getStatusCode()));
- Parameters:
metadata
- Metadata to associate with the container. 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.
- Throws:
UnsupportedOperationException
- If one ofMatchConditions.getIfMatch()
,MatchConditions.getIfNoneMatch()
, orRequestConditions.getIfUnmodifiedSince()
is set.
-
getAccessPolicy
Returns the container's permissions. The permissions indicate whether container's blobs may be accessed publicly. For more information, see the Azure Docs.Code Samples
client.getAccessPolicy().subscribe(response -> { System.out.printf("Blob Access Type: %s%n", response.getBlobAccessType()); for (BlobSignedIdentifier identifier : response.getIdentifiers()) { System.out.printf("Identifier Name: %s, Permissions %s%n", identifier.getId(), identifier.getAccessPolicy().getPermissions()); } });
- Returns:
- A reactive response containing the container access policy.
-
getAccessPolicyWithResponse
public Mono<com.azure.core.http.rest.Response<BlobContainerAccessPolicies>> getAccessPolicyWithResponse(String leaseId) Returns the container's permissions. The permissions indicate whether container's blobs may be accessed publicly. For more information, see the Azure Docs.Code Samples
client.getAccessPolicyWithResponse(leaseId).subscribe(response -> { System.out.printf("Blob Access Type: %s%n", response.getValue().getBlobAccessType()); for (BlobSignedIdentifier identifier : response.getValue().getIdentifiers()) { System.out.printf("Identifier Name: %s, Permissions %s%n", identifier.getId(), identifier.getAccessPolicy().getPermissions()); } });
- Parameters:
leaseId
- The lease ID the active lease on the container must match.- Returns:
- A reactive response containing the container access policy.
-
setAccessPolicy
public Mono<Void> setAccessPolicy(PublicAccessType accessType, List<BlobSignedIdentifier> identifiers) Sets the container's permissions. The permissions indicate whether blobs in a container may be accessed publicly. Note that, for each signed identifier, we will truncate the start and expiry times to the nearest second to ensure the time formatting is compatible with the service. For more information, see the Azure Docs.Code Samples
BlobSignedIdentifier identifier = new BlobSignedIdentifier() .setId("name") .setAccessPolicy(new BlobAccessPolicy() .setStartsOn(OffsetDateTime.now()) .setExpiresOn(OffsetDateTime.now().plusDays(7)) .setPermissions("permissionString")); client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier)).subscribe( response -> System.out.printf("Set access policy completed%n"), error -> System.out.printf("Set access policy failed: %s%n", error));
- Parameters:
accessType
- 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.identifiers
- A list ofBlobSignedIdentifier
objects that specify the permissions for the container. Please see here for more information. Passing null will clear all access policies.- Returns:
- A reactive response signalling completion.
-
setAccessPolicyWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> setAccessPolicyWithResponse(PublicAccessType accessType, List<BlobSignedIdentifier> identifiers, BlobRequestConditions requestConditions) Sets the container's permissions. The permissions indicate whether blobs in a container may be accessed publicly. Note that, for each signed identifier, we will truncate the start and expiry times to the nearest second to ensure the time formatting is compatible with the service. For more information, see the Azure Docs.Code Samples
BlobSignedIdentifier identifier = new BlobSignedIdentifier() .setId("name") .setAccessPolicy(new BlobAccessPolicy() .setStartsOn(OffsetDateTime.now()) .setExpiresOn(OffsetDateTime.now().plusDays(7)) .setPermissions("permissionString")); BlobRequestConditions requestConditions = new BlobRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER, Collections.singletonList(identifier), requestConditions) .subscribe(response -> System.out.printf("Set access policy completed with status %d%n", response.getStatusCode()));
- Parameters:
accessType
- 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.identifiers
- A list ofBlobSignedIdentifier
objects that specify the permissions for the container. Please see here for more information. Passing null will clear all access policies.requestConditions
-BlobRequestConditions
- Returns:
- A reactive response signalling completion.
- Throws:
UnsupportedOperationException
- If eitherMatchConditions.getIfMatch()
orMatchConditions.getIfNoneMatch()
is set.
-
listBlobs
Returns a reactive Publisher emitting all the blobs in this container lazily as needed. The directories are flattened and only actual blobs and no directories are returned.Blob names are returned in lexicographic order. For more information, see the Azure Docs.
E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the root level 'bar', will return
- foo/foo1
- foo/foo2
- bar
Code Samples
client.listBlobs().subscribe(blob -> System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isPrefix()));
- Returns:
- A reactive response emitting the flattened blobs.
-
listBlobs
Returns a reactive Publisher emitting all the blobs in this container lazily as needed. The directories are flattened and only actual blobs and no directories are returned.Blob names are returned in lexicographic order. For more information, see the Azure Docs.
E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the root level 'bar', will return
- foo/foo1
- foo/foo2
- bar
ListBlobsOptions options = new ListBlobsOptions() .setPrefix("prefixToMatch") .setDetails(new BlobListDetails() .setRetrieveDeletedBlobs(true) .setRetrieveSnapshots(true)); client.listBlobs(options).subscribe(blob -> System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", blob.getName(), blob.isPrefix(), blob.isDeleted(), blob.getSnapshot()));
- Parameters:
options
-ListBlobsOptions
- Returns:
- A reactive response emitting the listed blobs, flattened.
-
listBlobs
public com.azure.core.http.rest.PagedFlux<BlobItem> listBlobs(ListBlobsOptions options, String continuationToken) Returns a reactive Publisher emitting all the blobs in this container lazily as needed. The directories are flattened and only actual blobs and no directories are returned.Blob names are returned in lexicographic order. For more information, see the Azure Docs.
E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the root level 'bar', will return
- foo/foo1
- foo/foo2
- bar
ListBlobsOptions options = new ListBlobsOptions() .setPrefix("prefixToMatch") .setDetails(new BlobListDetails() .setRetrieveDeletedBlobs(true) .setRetrieveSnapshots(true)); String continuationToken = "continuationToken"; client.listBlobs(options, continuationToken).subscribe(blob -> System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", blob.getName(), blob.isPrefix(), blob.isDeleted(), blob.getSnapshot()));
- Parameters:
options
-ListBlobsOptions
continuationToken
- Identifies the portion of the list to be returned with the next list operation.- Returns:
- A reactive response emitting the listed blobs, flattened.
-
listBlobsByHierarchy
Returns a reactive Publisher emitting all the blobs and directories (prefixes) under the given directory (prefix). Directories will haveBlobItem.isPrefix()
set to true.Blob names are returned in lexicographic order. For more information, see the Azure Docs.
E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the root level 'bar', will return the following results when prefix=null:
- foo/ (isPrefix = true)
- bar (isPrefix = false)
will return the following results when prefix="foo/":
- foo/foo1 (isPrefix = false)
- foo/foo2 (isPrefix = false)
Code Samples
client.listBlobsByHierarchy("directoryName").subscribe(blob -> System.out.printf("Name: %s, Directory? %b%n", blob.getName(), blob.isDeleted()));
- Parameters:
directory
- The directory to list blobs underneath- Returns:
- A reactive response emitting the prefixes and blobs.
-
listBlobsByHierarchy
public com.azure.core.http.rest.PagedFlux<BlobItem> listBlobsByHierarchy(String delimiter, ListBlobsOptions options) Returns a reactive Publisher emitting all the blobs and prefixes (directories) under the given prefix (directory). Directories will haveBlobItem.isPrefix()
set to true.Blob names are returned in lexicographic order. For more information, see the Azure Docs.
E.g. listing a container containing a 'foo' folder, which contains blobs 'foo1' and 'foo2', and a blob on the root level 'bar', will return the following results when prefix=null:
- foo/ (isPrefix = true)
- bar (isPrefix = false)
will return the following results when prefix="foo/":
- foo/foo1 (isPrefix = false)
- foo/foo2 (isPrefix = false)
Code Samples
ListBlobsOptions options = new ListBlobsOptions() .setPrefix("directoryName") .setDetails(new BlobListDetails() .setRetrieveDeletedBlobs(true) .setRetrieveSnapshots(true)); client.listBlobsByHierarchy("/", options).subscribe(blob -> System.out.printf("Name: %s, Directory? %b, Deleted? %b, Snapshot ID: %s%n", blob.getName(), blob.isPrefix(), blob.isDeleted(), blob.getSnapshot()));
- Parameters:
delimiter
- The delimiter for blob hierarchy, "/" for hierarchy based on directoriesoptions
-ListBlobsOptions
- Returns:
- A reactive response emitting the prefixes and blobs.
-
findBlobsByTags
Returns a reactive Publisher emitting the blobs in this container whose tags match the query expression. For more information, including information on the query syntax, see the Azure Docs.Code Samples
client.findBlobsByTags("where=tag=value").subscribe(blob -> System.out.printf("Name: %s%n", blob.getName()));
- Parameters:
query
- Filters the results to return only blobs whose tags match the specified expression.- Returns:
- A reactive response emitting the list of blobs.
-
findBlobsByTags
Returns a reactive Publisher emitting the blobs in this container whose tags match the query expression. For more information, including information on the query syntax, see the Azure Docs.Code Samples
client.findBlobsByTags(new FindBlobsOptions("where=tag=value").setMaxResultsPerPage(10)) .subscribe(blob -> System.out.printf("Name: %s%n", blob.getName()));
- Parameters:
options
-FindBlobsOptions
- Returns:
- A reactive response emitting the list of blobs.
-
getAccountInfo
Returns the sku name and account kind for the account. For more information, please see the Azure Docs.Code Samples
client.getAccountInfo().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n", response.getAccountKind(), response.getSkuName()));
- Returns:
- A reactive response containing the account info.
-
getAccountInfoWithResponse
Returns the sku name and account kind for the account. For more information, please see the Azure Docs.Code Samples
client.getAccountInfoWithResponse().subscribe(response -> System.out.printf("Account Kind: %s, SKU: %s%n", response.getValue().getAccountKind(), response.getValue().getSkuName()));
- Returns:
- A reactive response containing the account info.
-
generateUserDelegationSas
public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey) Generates a user delegation SAS for the container using the specifiedBlobServiceSasSignatureValues
.See
BlobServiceSasSignatureValues
for more information on how to construct a user delegation SAS.Code Samples
OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) .setStartTime(OffsetDateTime.now()); client.generateUserDelegationSas(values, userDelegationKey);
- Parameters:
blobServiceSasSignatureValues
-BlobServiceSasSignatureValues
userDelegationKey
- AUserDelegationKey
object used to sign the SAS values. SeeBlobServiceAsyncClient.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 container using the specifiedBlobServiceSasSignatureValues
.See
BlobServiceSasSignatureValues
for more information on how to construct a user delegation SAS.Code Samples
OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); BlobContainerSasPermission myPermission = new BlobContainerSasPermission().setReadPermission(true); BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission) .setStartTime(OffsetDateTime.now()); client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context("key", "value"));
- Parameters:
blobServiceSasSignatureValues
-BlobServiceSasSignatureValues
userDelegationKey
- AUserDelegationKey
object used to sign the SAS values. SeeBlobServiceAsyncClient.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
Generates a service SAS for the container using the specifiedBlobServiceSasSignatureValues
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); BlobContainerSasPermission permission = new BlobContainerSasPermission().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 container using the specifiedBlobServiceSasSignatureValues
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); BlobContainerSasPermission permission = new BlobContainerSasPermission().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.
-