共用方式為


CloudStorageAccount Class

  • java.lang.Object
    • com.microsoft.azure.storage.CloudStorageAccount

public class CloudStorageAccount

Represents a Microsoft Azure storage account.

Field Summary

Modifier and Type Field and Description
final String ACCOUNT_KEY_NAME

Represents the setting name for the account key.

final String ACCOUNT_NAME_NAME

Represents the setting name for the account name.

final String ACCOUNT_TOKEN_NAME

Represents the setting name for the token credential.

final String BLOB_ENDPOINT_NAME

Represents the setting name for a custom blob storage endpoint.

final String BLOB_SECONDARY_ENDPOINT_NAME

Represents the setting name for a custom blob storage secondary endpoint.

final String QUEUE_ENDPOINT_NAME

Represents the setting name for a custom queue endpoint.

final String QUEUE_SECONDARY_ENDPOINT_NAME

Represents the setting name for a custom queue secondary endpoint.

final String SHARED_ACCESS_SIGNATURE_NAME

Represents the setting name for a shared access key.

final String TABLE_ENDPOINT_NAME

Represents the setting name for a custom table storage endpoint.

final String TABLE_SECONDARY_ENDPOINT_NAME

Represents the setting name for a custom table storage secondary endpoint.

Constructor Summary

Constructor Description
CloudStorageAccount(final StorageCredentials storageCredentials)

Creates an instance of the class using the specified account credentials.

With this constructor, the object is constructed using the default HTTP storage service endpoints. The default HTTP storage service endpoints are , , , and , where is the name of your storage account.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

CloudStorageAccount(final StorageCredentials storageCredentials, final boolean useHttps)

Creates an instance of the class using the specified account credentials and the default service endpoints, using HTTP or HTTPS as specified.

With this constructor, the object is constructed using the default storage service endpoints. The default storage service endpoints are: ; ; ; and , where is the name of your storage account. Access to the cloud storage account may be via HTTP or HTTPS, as specified by the parameter.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

CloudStorageAccount(final StorageCredentials storageCredentials, final boolean useHttps, final String endpointSuffix)

Creates an instance of the class using the specified account credentials.

With this constructor, the object is constructed using the given HTTP storage service endpoint suffix (if any, otherwise the default is used).

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

CloudStorageAccount(final StorageCredentials storageCredentials, final boolean useHttps, final String endpointSuffix, String accountName)

Creates an instance of the class using the specified account credentials.

With this constructor, the object is constructed using the given HTTP storage service endpoint suffix (if any, otherwise the default is used).

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

CloudStorageAccount(final StorageCredentials storageCredentials, final StorageUri blobStorageUri, final StorageUri queueStorageUri, final StorageUri tableStorageUri)

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

Use this constructor to construct a object using custom endpoints, in the case where you've configured a custom domain name for your storage account.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

CloudStorageAccount(final StorageCredentials storageCredentials, final StorageUri blobStorageUri, final StorageUri queueStorageUri, final StorageUri tableStorageUri, final StorageUri fileStorageUri)

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

Use this constructor to construct a object using custom endpoints, in the case where you've configured a custom domain name for your storage account.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

CloudStorageAccount(final StorageCredentials storageCredentials, final URI blobEndpoint, final URI queueEndpoint, final URI tableEndpoint)

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

Use this constructor to construct a object using custom endpoints, in the case where you've configured a custom domain name for your storage account.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

CloudStorageAccount(final StorageCredentials storageCredentials, final URI blobEndpoint, final URI queueEndpoint, final URI tableEndpoint, final URI fileEndpoint)

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

Use this constructor to construct a object using custom endpoints, in the case where you've configured a custom domain name for your storage account.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

Method Summary

Modifier and Type Method and Description
CloudAnalyticsClient createCloudAnalyticsClient()

Creates a new Analytics service client.

CloudBlobClient createCloudBlobClient()

Creates a new Blob service client.

CloudFileClient createCloudFileClient()

Creates a new File service client.

CloudQueueClient createCloudQueueClient()

Creates a new Queue service client.

CloudTableClient createCloudTableClient()

Creates a new Table service client.

String generateSharedAccessSignature(SharedAccessAccountPolicy policy)

Returns a shared access signature for the account.

URI getBlobEndpoint()

Returns the endpoint for the Blob service for the storage account. This method is not supported when using shared access signature credentials.

StorageUri getBlobStorageUri()

Returns the endpoint for the Blob service for the storage account. This method is not supported when using shared access signature credentials.

StorageCredentials getCredentials()

Returns the credentials for the storage account.

CloudStorageAccount getDevelopmentStorageAccount()

Returns a CloudStorageAccount object that represents the development storage credentials. Secondary endpoints are enabled by default.

CloudStorageAccount getDevelopmentStorageAccount(final URI proxyUri)

Returns a CloudStorageAccount object that represents the development storage credentials, using the specified proxy URI. Secondary endpoints are enabled by default.

String getEndpointSuffix()

If an endpoint suffix was specified, return it

URI getFileEndpoint()

Returns the endpoint for the File service for the storage account. This method is not supported when using shared access signature credentials.

StorageUri getFileStorageUri()

Returns the endpoint for the File service for the storage account. This method is not supported when using shared access signature credentials.

URI getQueueEndpoint()

Returns the endpoint for the Queue service for the storage account.

StorageUri getQueueStorageUri()

Returns the endpoint for the Queue service for the storage account.

URI getTableEndpoint()

Returns the endpoint for the Table service for the storage account.

StorageUri getTableStorageUri()

Returns the endpoint for the Table service for the storage account.

CloudStorageAccount parse(final String connectionString)

Parses a connection string and returns a cloud storage account created from the connection string.

The connection string should be in the Azure connection string format.

Note that while a connection string may include a SAS token, it is often easier to use the CloudBlobContainer(final URI uri), CloudQueue(final URI uri), CloudTable(final URI uri) constructors directly. To do this, create a StorageCredentialsSharedAccessSignature(final String token) object with your SAS token, use the transformUri(final URI resourceUri) method on the container, queue, or table URI, and then use that URI to construct the object.

void setCredentials(final StorageCredentials credentials)

Sets the StorageCredentials to use with this account. Warning: for internal use only, as updating the credentials to a new account can invalidate pre-existing objects.

String toString()

Returns a connection string for this storage account, without sensitive data.

String toString(final boolean exportSecrets)

Returns a connection string for this storage account, optionally with sensitive data.

Field Details

ACCOUNT_KEY_NAME

protected static final String ACCOUNT_KEY_NAME= "AccountKey"

Represents the setting name for the account key.

ACCOUNT_NAME_NAME

protected static final String ACCOUNT_NAME_NAME= "AccountName"

Represents the setting name for the account name.

ACCOUNT_TOKEN_NAME

protected static final String ACCOUNT_TOKEN_NAME= "AccountToken"

Represents the setting name for the token credential.

BLOB_ENDPOINT_NAME

protected static final String BLOB_ENDPOINT_NAME= "BlobEndpoint"

Represents the setting name for a custom blob storage endpoint.

BLOB_SECONDARY_ENDPOINT_NAME

protected static final String BLOB_SECONDARY_ENDPOINT_NAME= "BlobSecondaryEndpoint"

Represents the setting name for a custom blob storage secondary endpoint.

QUEUE_ENDPOINT_NAME

protected static final String QUEUE_ENDPOINT_NAME= "QueueEndpoint"

Represents the setting name for a custom queue endpoint.

QUEUE_SECONDARY_ENDPOINT_NAME

protected static final String QUEUE_SECONDARY_ENDPOINT_NAME= "QueueSecondaryEndpoint"

Represents the setting name for a custom queue secondary endpoint.

SHARED_ACCESS_SIGNATURE_NAME

protected static final String SHARED_ACCESS_SIGNATURE_NAME= "SharedAccessSignature"

Represents the setting name for a shared access key.

TABLE_ENDPOINT_NAME

protected static final String TABLE_ENDPOINT_NAME= "TableEndpoint"

Represents the setting name for a custom table storage endpoint.

TABLE_SECONDARY_ENDPOINT_NAME

protected static final String TABLE_SECONDARY_ENDPOINT_NAME= "TableSecondaryEndpoint"

Represents the setting name for a custom table storage secondary endpoint.

Constructor Details

CloudStorageAccount

public CloudStorageAccount(final StorageCredentials storageCredentials)

Creates an instance of the class using the specified account credentials.

With this constructor, the object is constructed using the default HTTP storage service endpoints. The default HTTP storage service endpoints are , , , and , where is the name of your storage account.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

Parameters:

storageCredentials - A StorageCredentials object that represents the storage credentials to use to authenticate this account.

Throws:

URISyntaxException - If storageCredentials specify an invalid account name.

CloudStorageAccount

public CloudStorageAccount(final StorageCredentials storageCredentials, final boolean useHttps)

Creates an instance of the class using the specified account credentials and the default service endpoints, using HTTP or HTTPS as specified.

With this constructor, the object is constructed using the default storage service endpoints. The default storage service endpoints are: ; ; ; and , where is the name of your storage account. Access to the cloud storage account may be via HTTP or HTTPS, as specified by the parameter.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

Parameters:

storageCredentials - A StorageCredentials object that represents the storage credentials to use to authenticate this account.
useHttps -

true to use HTTPS to connect to the storage service endpoints; otherwise, false.

Throws:

URISyntaxException - If storageCredentials specify an invalid account name.

CloudStorageAccount

public CloudStorageAccount(final StorageCredentials storageCredentials, final boolean useHttps, final String endpointSuffix)

Creates an instance of the class using the specified account credentials.

With this constructor, the object is constructed using the given HTTP storage service endpoint suffix (if any, otherwise the default is used).

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

Parameters:

storageCredentials - A StorageCredentials object that represents the storage credentials to use to authenticate this account.
useHttps -

true to use HTTPS to connect to the storage service endpoints; otherwise, false.

endpointSuffix - A String that represents the endpointSuffix to use, if any.

Throws:

URISyntaxException - If storageCredentials specify an invalid account name.

CloudStorageAccount

public CloudStorageAccount(final StorageCredentials storageCredentials, final boolean useHttps, final String endpointSuffix, String accountName)

Creates an instance of the class using the specified account credentials.

With this constructor, the object is constructed using the given HTTP storage service endpoint suffix (if any, otherwise the default is used).

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

Parameters:

storageCredentials - A StorageCredentials object that represents the storage credentials to use to authenticate this account.
useHttps -

true to use HTTPS to connect to the storage service endpoints; otherwise, false.

endpointSuffix - A String that represents the endpointSuffix to use, if any.
accountName - A String that contains the account name. This will be used in place of a nullgetAccountName(), but the two must match if both are not null.

Throws:

URISyntaxException - If storageCredentials specify an invalid account name.

CloudStorageAccount

public CloudStorageAccount(final StorageCredentials storageCredentials, final StorageUri blobStorageUri, final StorageUri queueStorageUri, final StorageUri tableStorageUri)

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

Use this constructor to construct a object using custom endpoints, in the case where you've configured a custom domain name for your storage account.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

Parameters:

storageCredentials - A StorageCredentials object that represents the storage credentials to use to authenticate this account.
blobStorageUri - A StorageUri object that represents the Blob service endpoint.
queueStorageUri - A StorageUri object that represents the Queue service endpoint.
tableStorageUri - A StorageUri object that represents the Table service endpoint.

CloudStorageAccount

public CloudStorageAccount(final StorageCredentials storageCredentials, final StorageUri blobStorageUri, final StorageUri queueStorageUri, final StorageUri tableStorageUri, final StorageUri fileStorageUri)

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

Use this constructor to construct a object using custom endpoints, in the case where you've configured a custom domain name for your storage account.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

Parameters:

storageCredentials - A StorageCredentials object that represents the storage credentials to use to authenticate this account.
blobStorageUri - A StorageUri object that represents the Blob service endpoint.
queueStorageUri - A StorageUri object that represents the Queue service endpoint.
tableStorageUri - A StorageUri object that represents the Table service endpoint.
fileStorageUri - A StorageUri object that represents the File service endpoint.

CloudStorageAccount

public CloudStorageAccount(final StorageCredentials storageCredentials, final URI blobEndpoint, final URI queueEndpoint, final URI tableEndpoint)

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

Use this constructor to construct a object using custom endpoints, in the case where you've configured a custom domain name for your storage account.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

Parameters:

storageCredentials - A StorageCredentials object that represents the storage credentials to use to authenticate this account.
blobEndpoint - A java.net.URI object that represents the Blob service endpoint.
queueEndpoint - A java.net.URI object that represents the Queue service endpoint.
tableEndpoint - A java.net.URI object that represents the Table service endpoint.

CloudStorageAccount

public CloudStorageAccount(final StorageCredentials storageCredentials, final URI blobEndpoint, final URI queueEndpoint, final URI tableEndpoint, final URI fileEndpoint)

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

Use this constructor to construct a object using custom endpoints, in the case where you've configured a custom domain name for your storage account.

The credentials provided when constructing the object are used to authenticate all further requests against resources that are accessed via the object or a client object created from it. A client object may be a CloudBlobClient object.

Parameters:

storageCredentials - A StorageCredentials object that represents the storage credentials to use to authenticate this account.
blobEndpoint - A java.net.URI object that represents the Blob service endpoint.
queueEndpoint - A java.net.URI object that represents the Queue service endpoint.
tableEndpoint - A java.net.URI object that represents the Table service endpoint.
fileEndpoint - A java.net.URI object that represents the File service endpoint.

Method Details

createCloudAnalyticsClient

public CloudAnalyticsClient createCloudAnalyticsClient()

Creates a new Analytics service client.

Returns:

An analytics client object that uses the Blob and Table service endpoints.

createCloudBlobClient

public CloudBlobClient createCloudBlobClient()

Creates a new Blob service client.

Returns:

A CloudBlobClient that represents the cloud Blob client.

createCloudFileClient

public CloudFileClient createCloudFileClient()

Creates a new File service client.

Returns:

A CloudFileClient that represents the cloud File client.

createCloudQueueClient

public CloudQueueClient createCloudQueueClient()

Creates a new Queue service client.

Returns:

A client object that uses the Queue service endpoint.

createCloudTableClient

public CloudTableClient createCloudTableClient()

Creates a new Table service client.

Returns:

A client object that uses the Table service endpoint.

generateSharedAccessSignature

public String generateSharedAccessSignature(SharedAccessAccountPolicy policy)

Returns a shared access signature for the account.

Parameters:

policy - A SharedAccessAccountPolicy specifying the access policy for the shared access signature.

Returns:

The query string returned includes the leading question mark.

Throws:

StorageException - If a storage service error occurred.
InvalidKeyException - If the key is invalid.

getBlobEndpoint

public URI getBlobEndpoint()

Returns the endpoint for the Blob service for the storage account. This method is not supported when using shared access signature credentials.

Returns:

A java.net.URI object that represents the Blob endpoint associated with this account.

getBlobStorageUri

public StorageUri getBlobStorageUri()

Returns the endpoint for the Blob service for the storage account. This method is not supported when using shared access signature credentials.

Returns:

A StorageUri object that represents the Blob endpoint associated with this account.

getCredentials

public StorageCredentials getCredentials()

Returns the credentials for the storage account.

Returns:

A StorageCredentials object that represents the credentials for this storage account.

getDevelopmentStorageAccount

public static CloudStorageAccount getDevelopmentStorageAccount()

Returns a CloudStorageAccount object that represents the development storage credentials. Secondary endpoints are enabled by default.

Returns:

A CloudStorageAccount object for the development storage credentials.

getDevelopmentStorageAccount

public static CloudStorageAccount getDevelopmentStorageAccount(final URI proxyUri)

Returns a CloudStorageAccount object that represents the development storage credentials, using the specified proxy URI. Secondary endpoints are enabled by default.

Parameters:

proxyUri - A java.net.URI object that represents the proxy endpoint to use. Specifying null will use the default http://127.0.0.1.

Returns:

A CloudStorageAccount object for the development storage credentials.

Throws:

URISyntaxException - If the resource URI is invalid.

getEndpointSuffix

public String getEndpointSuffix()

If an endpoint suffix was specified, return it

Returns:

the endpoint suffix

getFileEndpoint

public URI getFileEndpoint()

Returns the endpoint for the File service for the storage account. This method is not supported when using shared access signature credentials.

Returns:

A java.net.URI object that represents the File endpoint associated with this account.

getFileStorageUri

public StorageUri getFileStorageUri()

Returns the endpoint for the File service for the storage account. This method is not supported when using shared access signature credentials.

Returns:

A StorageUri object that represents the File endpoint associated with this account.

getQueueEndpoint

public URI getQueueEndpoint()

Returns the endpoint for the Queue service for the storage account.

Returns:

A java.net.URI object that represents the queue endpoint associated with this account.

getQueueStorageUri

public StorageUri getQueueStorageUri()

Returns the endpoint for the Queue service for the storage account.

Returns:

A StorageUri object that represents the Queue endpoint associated with this account.

getTableEndpoint

public URI getTableEndpoint()

Returns the endpoint for the Table service for the storage account.

Returns:

A StorageUri object that represents the Table endpoint associated with this account.

getTableStorageUri

public StorageUri getTableStorageUri()

Returns the endpoint for the Table service for the storage account.

Returns:

A java.net.URI object that represents the Table endpoint associated with this account.

parse

public static CloudStorageAccount parse(final String connectionString)

Parses a connection string and returns a cloud storage account created from the connection string.

The connection string should be in the Azure connection string format.

Note that while a connection string may include a SAS token, it is often easier to use the CloudBlobContainer(final URI uri), CloudQueue(final URI uri), CloudTable(final URI uri) constructors directly. To do this, create a StorageCredentialsSharedAccessSignature(final String token) object with your SAS token, use the transformUri(final URI resourceUri) method on the container, queue, or table URI, and then use that URI to construct the object.

Parameters:

connectionString - A String that represents the connection string to parse.

Returns:

A CloudStorageAccount object that represents the cloud storage account constructed from the values provided in the connection string.

Throws:

InvalidKeyException - If credentials in the connection string contain an invalid key.
URISyntaxException - If the connection string specifies an invalid URI.

setCredentials

protected void setCredentials(final StorageCredentials credentials)

Sets the StorageCredentials to use with this account. Warning: for internal use only, as updating the credentials to a new account can invalidate pre-existing objects.

Parameters:

credentials - the credentials to set

toString

public String toString()

Returns a connection string for this storage account, without sensitive data.

Returns:

A String that represents the connection string for this storage account, without sensitive data.

toString

public String toString(final boolean exportSecrets)

Returns a connection string for this storage account, optionally with sensitive data.

Parameters:

exportSecrets -

true to include sensitive data in the string; otherwise, false.

Returns:

A String that represents the connection string for this storage account, optionally with sensitive data.

Applies to