你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

StorageCredentials 类

定义

表示用于对 Microsoft Azure 存储帐户的访问进行身份验证的一组凭据。

public sealed class StorageCredentials
type StorageCredentials = class
Public NotInheritable Class StorageCredentials
继承
StorageCredentials

示例


// Create a CloudStorageAccount object using account name and key.
// The account name should be just the name of a Storage Account, not a URI, and 
// not including the suffix. The key should be a base-64 encoded string that you
// can acquire from the portal, or from the management plane.
// This will have full permissions to all operations on the account.
StorageCredentials storageCredentials = new StorageCredentials(myAccountName, myAccountKey);
CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(storageCredentials, useHttps: true);

// Create a CloudBlobClient object from the storage account.
// This object is the root object for all operations on the 
// blob service for this particular account.
CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient();

// Get a reference to a CloudBlobContainer object in this account. 
// This object can be used to create the container on the service, 
// list blobs, delete the container, etc. This operation does not make a 
// call to the Azure Storage service.  It neither creates the container 
// on the service, nor validates its existence.
CloudBlobContainer container = blobClient.GetContainerReference("container1");


// Create a CloudQueueClient object from the storage account.
// This object is the root object for all operations on the 
// queue service for this particular account.
CloudQueueClient queueClient = cloudStorageAccount.CreateCloudQueueClient();

// Get a reference to a CloudQueue object in this account. 
// This object can be used to create the queue on the service, 
// delete the queue, add messages, etc. This operation does not
// make a call to the Azure Storage service.  It neither creates 
// the queue on the service, nor validates its existence.
CloudQueue queue = queueClient.GetQueueReference("queue1");

// Create a CloudFileClient object from the storage account.
// This object is the root object for all operations on the 
// file service for this particular account.
CloudFileClient fileClient = cloudStorageAccount.CreateCloudFileClient();

// Get a reference to a CloudFileShare object in this account. 
// This object can be used to create the share on the service, 
// delete the share, list files and directories, etc. This operation 
// does not make a call to the Azure Storage service. It neither 
// creates the share on the service, nor validates its existence.
CloudFileShare share = fileClient.GetShareReference("share1");

构造函数

StorageCredentials()

初始化 StorageCredentials 类的新实例。

StorageCredentials(String)

使用指定的共享访问签名令牌初始化 StorageCredentials 类的新实例。

StorageCredentials(String, Byte[])

使用指定的帐户名称和密钥值初始化 StorageCredentials 类的新实例。

StorageCredentials(String, Byte[], String)

使用指定的帐户名称、密钥值和密钥名称初始化 StorageCredentials 类的新实例。

StorageCredentials(String, String)

使用指定的帐户名称和密钥值初始化 StorageCredentials 类的新实例。

StorageCredentials(String, String, String)

使用指定的帐户名称、密钥值和密钥名称初始化 StorageCredentials 类的新实例。

StorageCredentials(TokenCredential)

使用指定的持有者标记初始化 类的新实例 StorageCredentials

属性

AccountName

获取凭据的关联帐户名。

IsAnonymous

获取一个值,该值指示凭据是否用于匿名访问。

IsSAS

获取一个值,该值指示凭据是否为共享访问签名令牌。

IsSharedKey

获取一个值,该值指示凭据是否为共享密钥。

IsToken

获取一个值,该值指示凭据是否为持有者令牌。

KeyName

获取凭据的关联密钥名称。

SASSignature

获取共享访问签名令牌的 sig 参数的值。

SASToken

获取凭据的关联共享访问签名令牌。

方法

Equals(StorageCredentials)

通过比较 SAS 令牌、帐户名称、密钥名称和密钥值,来确定是否有其他 StorageCredentials 对象等于此对象。

ExportBase64EncodedKey()

将帐户访问密钥的值导出为 Base64 编码字符串。

ExportKey()

返回凭据的帐户密钥。

TransformUri(StorageUri)

通过追加共享访问标记将资源 URI 转换为共享访问签名 URI。

TransformUri(Uri)

通过追加共享访问标记将资源 URI 转换为共享访问签名 URI。

UpdateKey(Byte[])

更新凭据的密钥值。

UpdateKey(Byte[], String)

更新凭据的密钥值和密钥名称。

UpdateKey(String)

更新凭据的密钥值。

UpdateKey(String, String)

更新凭据的密钥值和密钥名称。

UpdateSASToken(String)

更新使用共享访问签名创建的存储凭据的共享访问签名 (SAS) 令牌值。

适用于