如何将参数传递给存储Uri?

时间:2016-03-28 13:25:31

标签: azure c#-4.0

我正在研究azure你能不能帮助我如何将参数传递给azure中的storageUri。

这里他们有5个参数信条,blob,队列,表格,文件     如何传递参数storageuri?请查看以下代码。

enter code here  
      Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = null;
        string AccountName = RoleEnvironment.GetConfigurationSettingValue("AccountName");
        string AccountKey = RoleEnvironment.GetConfigurationSettingValue("AccountKey");
        StorageCredentialsAccountAndKey credentials = new StorageCredentialsAccountAndKey(AccountName, AccountKey);
        storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(credentials,
                                                              new StorageUri(),
                                                              new StorageUri("https://{0}.queue.core.windows.net"),
                                                              new StorageUri("https://{0}.table.core.windows.net"),
                                                               new StorageUri("https://{0}.table.core.windows.net"));

1 个答案:

答案 0 :(得分:1)

尝试以下内容:

        var credentials = new StorageCredentials(accountName, accountKey);
         CloudStorageAccount storageAccount = new CloudStorageAccount(credentials,
             new StorageUri(new Uri(string.Format("https://{0}.blob.core.windows.net", accountName))),
             new StorageUri(new Uri(string.Format("https://{0}.queue.core.windows.net", accountName))),
             new StorageUri(new Uri(string.Format("https://{0}.table.core.windows.net", accountName))),
             new StorageUri(new Uri(string.Format("https://{0}.file.core.windows.net", accountName)))
             );