CloudBlobClient Class

  • java.lang.Object

public class CloudBlobClient extends ServiceClient

Provides a client for accessing the Microsoft Azure Blob service.

This class provides a point of access to the Blob service. The service client encapsulates the base URI for the Blob service. If the service client will be used for authenticated access, it also encapsulates the credentials for accessing the storage account.

Constructor Summary

Constructor Description
CloudBlobClient(final StorageUri baseUri)

Creates an instance of the class using the specified Blob service endpoint and anonymous credentials.

CloudBlobClient(final StorageUri storageUri, StorageCredentials credentials)

Creates an instance of the class using the specified Blob service endpoint and account credentials.

CloudBlobClient(final URI baseUri)

Creates an instance of the class using the specified Blob service endpoint and anonymous credentials.

CloudBlobClient(final URI baseUri, StorageCredentials credentials)

Creates an instance of the class using the specified Blob service endpoint and account credentials.

Method Summary

Modifier and Type Method and Description
AccountInformation downloadAccountInfo()

Gets information related to the storage account.

AccountInformation downloadAccountInfo(BlobRequestOptions options, OperationContext opContext)

Gets information related to the storage account.

StorageRequest<ServiceClient, Void, AccountInformation> downloadAccountInformationImpl(final RequestOptions options)
final ServiceProperties downloadServiceProperties()

Retrieves the current ServiceProperties for the given storage service. This includes Logging, HourMetrics, MinuteMetrics and CORS configurations.

final ServiceProperties downloadServiceProperties(BlobRequestOptions options, OperationContext opContext)

Retrieves the current ServiceProperties for the given storage service. This includes Logging, HourMetrics, MinuteMetrics and CORS configurations.

<P, T> Map<P, T> executeBatch(BlobBatchOperation<P, T> batch)

Executes a pre-constructed batch operation on the blob service. For more information on constructing blob batch requests, see BlobBatchOperation<P,R>.

<P, T> Map<P, T> executeBatch(BlobBatchOperation<P, T> batch, BlobRequestOptions requestOptions, OperationContext operationContext)

Executes a pre-constructed batch operation on the blob service. For more information on constructing blob batch requests, see BlobBatchOperation<P,R>.

CloudBlobContainer getContainerReference(final String containerName)

Gets a CloudBlobContainer object with the specified name.

BlobRequestOptions getDefaultRequestOptions()

Gets the BlobRequestOptions that is used for requests associated with this

String getDirectoryDelimiter()

Returns the value for the default delimiter used for cloud blob directories. The default is '/'.

ServiceStats getServiceStats()

Queries the service for the ServiceStats.

ServiceStats getServiceStats(BlobRequestOptions options, OperationContext opContext)

Queries the given storage service for the ServiceStats.

UserDelegationKey getUserDelegationKey(Date keyStart, Date keyEnd)

Requests a new user delegation key based on this client's oauth credentials.

UserDelegationKey getUserDelegationKey(Date keyStart, Date keyEnd, BlobRequestOptions options, OperationContext opContext)

Requests a new user delegation key based on this client's oauth credentials.

boolean isUsePathStyleUris()

Indicates whether path-style URIs are being used.

Iterable<CloudBlobContainer> listContainers()

Returns an enumerable collection of blob containers for this Blob service client.

Iterable<CloudBlobContainer> listContainers(final String prefix)

Returns an enumerable collection of blob containers whose names begin with the specified prefix for this Blob service client.

Iterable<CloudBlobContainer> listContainers(final String prefix, final ContainerListingDetails detailsIncluded, final BlobRequestOptions options, final OperationContext opContext)

Returns an enumerable collection of blob containers whose names begin with the specified prefix for this Blob service client, using the specified details setting, request options, and operation context.

ResultSegment<CloudBlobContainer> listContainersSegmented()

Returns a result segment of an enumerable collection of blob containers for this Blob service client.

ResultSegment<CloudBlobContainer> listContainersSegmented(final String prefix)

Returns a result segment of an enumerable collection of blob containers whose names begin with the specified prefix for this Blob service client.

ResultSegment<CloudBlobContainer> listContainersSegmented(final String prefix, final ContainerListingDetails detailsIncluded, final Integer maxResults, final ResultContinuation continuationToken, final BlobRequestOptions options, final OperationContext opContext)

Returns a result segment of an enumerable collection of blob containers whose names begin with the specified prefix for this Blob service client, using the specified listing details options, request options, and operation context.

void setDefaultRequestOptions(BlobRequestOptions defaultRequestOptions)

Sets the BlobRequestOptions that is used for any requests associated with this object.

void setDirectoryDelimiter(final String directoryDelimiter)

Sets the value for the default delimiter used for cloud blob directories.

void uploadServiceProperties(final ServiceProperties properties)

Uploads a new ServiceProperties configuration to the given storage service. This includes Logging, HourMetrics, MinuteMetrics and CORS configurations.

void uploadServiceProperties(final ServiceProperties properties, BlobRequestOptions options, OperationContext opContext)

Uploads a new ServiceProperties configuration to the given storage service. This includes Logging, HourMetrics, MinuteMetrics and CORS configurations.

Inherited Members

Constructor Details

CloudBlobClient

public CloudBlobClient(final StorageUri baseUri)

Creates an instance of the class using the specified Blob service endpoint and anonymous credentials.

Parameters:

baseUri - A StorageUri object that represents the Blob service endpoint used to create the client.

CloudBlobClient

public CloudBlobClient(final StorageUri storageUri, StorageCredentials credentials)

Creates an instance of the class using the specified Blob service endpoint and account credentials.

Parameters:

storageUri - A StorageUri object that represents the Blob service endpoint used to create the client.
credentials - A StorageCredentials object that represents the account credentials.

CloudBlobClient

public CloudBlobClient(final URI baseUri)

Creates an instance of the class using the specified Blob service endpoint and anonymous credentials.

Parameters:

baseUri - A java.net.URI object that represents the Blob service endpoint used to create the client.

CloudBlobClient

public CloudBlobClient(final URI baseUri, StorageCredentials credentials)

Creates an instance of the class using the specified Blob service endpoint and account credentials.

Parameters:

baseUri - A java.net.URI object that represents the Blob service endpoint used to create the client.
credentials - A StorageCredentials object that represents the account credentials.

Method Details

downloadAccountInfo

public AccountInformation downloadAccountInfo()

Gets information related to the storage account.

Returns:

A AccountInformation object for the given storage account.

Throws:

StorageException - If a storage service error occurred.

downloadAccountInfo

public AccountInformation downloadAccountInfo(BlobRequestOptions options, OperationContext opContext)

Gets information related to the storage account.

Parameters:

options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A AccountInformation object for the given storage account.

Throws:

StorageException - If a storage service error occurred.

downloadAccountInformationImpl

protected StorageRequest downloadAccountInformationImpl(final RequestOptions options)

Parameters:

options

downloadServiceProperties

public final ServiceProperties downloadServiceProperties()

Retrieves the current ServiceProperties for the given storage service. This includes Logging, HourMetrics, MinuteMetrics and CORS configurations.

Returns:

A ServiceProperties object representing the current configuration of the service.

Throws:

StorageException - If a storage service error occurred.

downloadServiceProperties

public final ServiceProperties downloadServiceProperties(BlobRequestOptions options, OperationContext opContext)

Retrieves the current ServiceProperties for the given storage service. This includes Logging, HourMetrics, MinuteMetrics and CORS configurations.

Parameters:

options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A ServiceProperties object representing the current configuration of the service.

Throws:

StorageException - If a storage service error occurred.

executeBatch

public Map executeBatch(BlobBatchOperation batch)

Executes a pre-constructed batch operation on the blob service. For more information on constructing blob batch requests, see BlobBatchOperation<P,R>.

Parameters:

batch - The batch of operations to execute.

Returns:

A mapping from parent object in the batch to the response for that parent.

Throws:

BatchException - Throws this subset of storage exception if one or more individual requests on the batch fail.
StorageException - Throws if an error with the service occurs.

executeBatch

public Map executeBatch(BlobBatchOperation batch, BlobRequestOptions requestOptions, OperationContext operationContext)

Executes a pre-constructed batch operation on the blob service. For more information on constructing blob batch requests, see BlobBatchOperation<P,R>.

Parameters:

batch - The batch of operations to execute.
requestOptions - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
operationContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A mapping from parent object in the batch to the response for that parent.

Throws:

BatchException - Throws this subset of storage exception if one or more individual requests on the batch fail.
StorageException - Throws if an error with the service occurs.

getContainerReference

public CloudBlobContainer getContainerReference(final String containerName)

Gets a CloudBlobContainer object with the specified name.

Parameters:

containerName - The name of the container, which must adhere to container naming rules. The container name should not include any path separator characters (/). Container names must be lowercase, between 3-63 characters long and must start with a letter or number. Container names may contain only letters, numbers, and the dash (-) character.

Returns:

A reference to a CloudBlobContainer object.

Throws:

URISyntaxException - If the resource URI constructed based on the containerName is invalid.
StorageException - If a storage service error occurred.

getDefaultRequestOptions

public BlobRequestOptions getDefaultRequestOptions()

Gets the BlobRequestOptions that is used for requests associated with this

Returns:

The BlobRequestOptions object containing the values used by this CloudBlobClient

getDirectoryDelimiter

public String getDirectoryDelimiter()

Returns the value for the default delimiter used for cloud blob directories. The default is '/'.

Returns:

A String which represents the value for the default delimiter.

getServiceStats

public ServiceStats getServiceStats()

Queries the service for the ServiceStats.

Returns:

A ServiceStats object for the given storage service.

Throws:

StorageException - If a storage service error occurred.

getServiceStats

public ServiceStats getServiceStats(BlobRequestOptions options, OperationContext opContext)

Queries the given storage service for the ServiceStats.

Parameters:

options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A ServiceStats object for the given storage service.

Throws:

StorageException - If a storage service error occurred.

getUserDelegationKey

public UserDelegationKey getUserDelegationKey(Date keyStart, Date keyEnd)

Requests a new user delegation key based on this client's oauth credentials.

Parameters:

keyStart - Start time of the requested key's validity.
keyEnd - End time of the requested key's validity.

Returns:

The requested key.

Throws:

StorageException

getUserDelegationKey

public UserDelegationKey getUserDelegationKey(Date keyStart, Date keyEnd, BlobRequestOptions options, OperationContext opContext)

Requests a new user delegation key based on this client's oauth credentials.

Parameters:

keyStart - Start time of the requested key's validity.
keyEnd - End time of the requested key's validity.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

The requested key.

Throws:

StorageException

isUsePathStyleUris

protected boolean isUsePathStyleUris()

Indicates whether path-style URIs are being used.

Returns:

true if using path-style URIs; otherwise, false.

listContainers

public Iterable listContainers()

Returns an enumerable collection of blob containers for this Blob service client.

Returns:

An enumerable collection of CloudBlobContainer objects retrieved lazily that represent the containers for this client.

listContainers

public Iterable listContainers(final String prefix)

Returns an enumerable collection of blob containers whose names begin with the specified prefix for this Blob service client.

Parameters:

prefix - A String that represents the container name prefix.

Returns:

An enumerable collection of CloudBlobContainer objects retrieved lazily that represent the containers for this client whose names begin with the specified prefix.

listContainers

public Iterable listContainers(final String prefix, final ContainerListingDetails detailsIncluded, final BlobRequestOptions options, final OperationContext opContext)

Returns an enumerable collection of blob containers whose names begin with the specified prefix for this Blob service client, using the specified details setting, request options, and operation context.

Parameters:

prefix - A String that represents the container name prefix.
detailsIncluded - A ContainerListingDetails value that indicates whether container metadata will be returned.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

An enumerable collection of CloudBlobContainer objects retrieved lazily that represents the containers for this client.

listContainersSegmented

public ResultSegment listContainersSegmented()

Returns a result segment of an enumerable collection of blob containers for this Blob service client.

Returns:

A ResultSegment<T> object that contains a segment of the enumerable collection of CloudBlobContainer objects that represent the containers for this client.

Throws:

StorageException - If a storage service error occurred.

listContainersSegmented

public ResultSegment listContainersSegmented(final String prefix)

Returns a result segment of an enumerable collection of blob containers whose names begin with the specified prefix for this Blob service client.

Parameters:

prefix - A String that represents the prefix of the container name.

Returns:

A ResultSegment<T> object that contains a segment of the enumerable collection of CloudBlobContainer objects that represent the containers whose names begin with the specified prefix.

Throws:

StorageException - If a storage service error occurred.

listContainersSegmented

public ResultSegment listContainersSegmented(final String prefix, final ContainerListingDetails detailsIncluded, final Integer maxResults, final ResultContinuation continuationToken, final BlobRequestOptions options, final OperationContext opContext)

Returns a result segment of an enumerable collection of blob containers whose names begin with the specified prefix for this Blob service client, using the specified listing details options, request options, and operation context.

Parameters:

prefix - A String that represents the prefix of the container name.
detailsIncluded - A ContainerListingDetails value that indicates whether container metadata will be returned.
maxResults - The maximum number of results to retrieve. If null or greater than 5000, the server will return up to 5,000 items. Must be at least 1.
continuationToken - A ResultContinuation object that represents a continuation token returned by a previous listing operation.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client (CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A ResultSegment<T> object that contains a segment of the enumerable collection of CloudBlobContainer objects that represent the containers for this Blob service client.

Throws:

StorageException - If a storage service error occurred.

setDefaultRequestOptions

public void setDefaultRequestOptions(BlobRequestOptions defaultRequestOptions)

Sets the BlobRequestOptions that is used for any requests associated with this object.

Parameters:

defaultRequestOptions - A BlobRequestOptions object which specifies the options to use.

setDirectoryDelimiter

public void setDirectoryDelimiter(final String directoryDelimiter)

Sets the value for the default delimiter used for cloud blob directories.

Parameters:

directoryDelimiter - A String that specifies the value for the default directory delimiter.

uploadServiceProperties

public void uploadServiceProperties(final ServiceProperties properties)

Uploads a new ServiceProperties configuration to the given storage service. This includes Logging, HourMetrics, MinuteMetrics and CORS configurations.

Parameters:

properties - A ServiceProperties object which specifies the service properties to upload.

Throws:

StorageException - If a storage service error occurred.

uploadServiceProperties

public void uploadServiceProperties(final ServiceProperties properties, BlobRequestOptions options, OperationContext opContext)

Uploads a new ServiceProperties configuration to the given storage service. This includes Logging, HourMetrics, MinuteMetrics and CORS configurations.

Parameters:

properties - A ServiceProperties object which specifies the service properties to upload.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

Applies to