【问题标题】:Azure: What are the Account Name and Access Key when using the Storage Emulator?Azure:使用存储模拟器时的帐户名称和访问密钥是什么?
【发布时间】:2012-02-01 17:27:58
【问题描述】:
【问题讨论】:
标签:
php
azure
connection-string
azure-blob-storage
【解决方案1】:
对于模拟器,存储帐户名称为devstoreaccount1
密钥是Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
这与语言、SDK 等无关,并且 SDK 通常具有用于开发存储的快捷方式(至少 .NET SDK 有)。例如,使用 .NET 和 C#,您无需了解模拟器帐户的详细信息:
var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
var blobClient = storageAccount.CreateCloudBlobClient();
【解决方案3】:
检查 .NET 存储客户端库 Microsoft.WindowsAzure.StorageClient.dll,您实际上可以找到构成这个“众所周知的”帐户名称和密钥的内置常量:
private const string DevstoreAccountName = "devstoreaccount1";
私有常量字符串 DevstoreAccountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
“Way back when”,在 CloudStorageAccount.DevelopmentStorageAccount 之前,我们曾经在连接到开发存储时自己输入这些数据。现在,为了方便起见,Microsoft 已将该连接字符串作为常量隐藏在 .dll 中。
private const string DevstoreCredentialInString = "AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";