Table of Contents

Class StorageCredentials

Namespace
Microsoft.WindowsAzure.Storage.Auth
Assembly
Microsoft.WindowsAzure.Storage.dll

Represents a set of credentials used to authenticate access to a Microsoft Azure storage account.

public sealed class StorageCredentials
Inheritance
StorageCredentials
Inherited Members

Remarks

Examples

Warning

It looks like the sample you are looking for does not exist.

Constructors

StorageCredentials()

Initializes a new instance of the StorageCredentials class.

public StorageCredentials()

StorageCredentials(TokenCredential)

Initializes a new instance of the StorageCredentials class with the specified bearer token.

public StorageCredentials(TokenCredential tokenCredential)

Parameters

tokenCredential TokenCredential

The authentication token.

StorageCredentials(string)

Initializes a new instance of the StorageCredentials class with the specified shared access signature token.

public StorageCredentials(string sasToken)

Parameters

sasToken string

A string representing the shared access signature token.

StorageCredentials(string, byte[])

Initializes a new instance of the StorageCredentials class with the specified account name and key value.

public StorageCredentials(string accountName, byte[] keyValue)

Parameters

accountName string

A string that represents the name of the storage account.

keyValue byte[]

An array of bytes that represent the account access key.

StorageCredentials(string, byte[], string)

Initializes a new instance of the StorageCredentials class with the specified account name, key value, and key name.

public StorageCredentials(string accountName, byte[] keyValue, string keyName)

Parameters

accountName string

A string that represents the name of the storage account.

keyValue byte[]

An array of bytes that represent the account access key.

keyName string

A string that represents the name of the key.

StorageCredentials(string, string)

Initializes a new instance of the StorageCredentials class with the specified account name and key value.

public StorageCredentials(string accountName, string keyValue)

Parameters

accountName string

A string that represents the name of the storage account.

keyValue string

A string that represents the Base64-encoded account access key.

StorageCredentials(string, string, string)

Initializes a new instance of the StorageCredentials class with the specified account name, key value, and key name.

public StorageCredentials(string accountName, string keyValue, string keyName)

Parameters

accountName string

A string that represents the name of the storage account.

keyValue string

A string that represents the Base64-encoded account access key.

keyName string

A string that represents the name of the key.

Properties

AccountName

Gets the associated account name for the credentials.

public string AccountName { get; }

Property Value

string

The account name.

IsAnonymous

Gets a value indicating whether the credentials are for anonymous access.

public bool IsAnonymous { get; }

Property Value

bool

true if the credentials are for anonymous access; otherwise, false.

IsSAS

Gets a value indicating whether the credentials are a shared access signature token.

public bool IsSAS { get; }

Property Value

bool

true if the credentials are a shared access signature token; otherwise, false.

IsSharedKey

Gets a value indicating whether the credentials are a shared key.

public bool IsSharedKey { get; }

Property Value

bool

true if the credentials are a shared key; otherwise, false.

IsToken

Gets a value indicating whether the credentials are a bearer token.

public bool IsToken { get; }

Property Value

bool

true if the credentials are a bearer token; otherwise, false.

KeyName

Gets the associated key name for the credentials.

public string KeyName { get; }

Property Value

string

The key name.

SASSignature

Gets the value of the shared access signature token's sig parameter.

public string SASSignature { get; }

Property Value

string

SASToken

Gets the associated shared access signature token for the credentials.

public string SASToken { get; }

Property Value

string

The shared access signature token.

Methods

Equals(StorageCredentials)

Determines whether an other StorageCredentials object is equal to this one by comparing their SAS tokens, account names, key names, and key values.

public bool Equals(StorageCredentials other)

Parameters

other StorageCredentials

The StorageCredentials object to compare to this one.

Returns

bool

true if the two StorageCredentials objects are equal; otherwise, false.

ExportBase64EncodedKey()

Exports the value of the account access key to a Base64-encoded string.

public string ExportBase64EncodedKey()

Returns

string

The account access key.

ExportKey()

Returns the account key for the credentials.

public byte[] ExportKey()

Returns

byte[]

An array of bytes that contains the key.

TransformUri(StorageUri)

Transforms a resource URI into a shared access signature URI, by appending a shared access token.

public StorageUri TransformUri(StorageUri resourceUri)

Parameters

resourceUri StorageUri

A StorageUri object that represents the resource URI to be transformed.

Returns

StorageUri

A StorageUri object that represents the signature, including the resource URI and the shared access token.

TransformUri(Uri)

Transforms a resource URI into a shared access signature URI, by appending a shared access token.

public Uri TransformUri(Uri resourceUri)

Parameters

resourceUri Uri

A System.Uri object that represents the resource URI to be transformed.

Returns

Uri

A System.Uri object that represents the signature, including the resource URI and the shared access token.

UpdateKey(byte[])

Updates the key value for the credentials.

public void UpdateKey(byte[] keyValue)

Parameters

keyValue byte[]

The key value, as an array of bytes, to update.

UpdateKey(byte[], string)

Updates the key value and key name for the credentials.

public void UpdateKey(byte[] keyValue, string keyName)

Parameters

keyValue byte[]

The key value, as an array of bytes, to update.

keyName string

The key name to update.

UpdateKey(string)

Updates the key value for the credentials.

public void UpdateKey(string keyValue)

Parameters

keyValue string

The key value, as a Base64-encoded string, to update.

UpdateKey(string, string)

Updates the key value and key name for the credentials.

public void UpdateKey(string keyValue, string keyName)

Parameters

keyValue string

The key value, as a Base64-encoded string, to update.

keyName string

The key name to update.

UpdateSASToken(string)

Updates the shared access signature (SAS) token value for storage credentials created with a shared access signature.

public void UpdateSASToken(string sasToken)

Parameters

sasToken string

A string that specifies the SAS token value to update.