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

标签 azure c#-4.0

我正在开发 azure,请帮我看看如何将参数传递给 azure 中的 storageUri。

这里有 5 个参数:credentials、blob、queue、table、file 如何传递参数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"));

最佳答案

尝试如下操作:

        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)))
             );

关于azure - 如何将参数传递给存储Uri?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36263336/

相关文章:

azure - Analysis Service 表格多维数据集刷新状态检查

azure - 修改Azure App Linux服务的nginx.conf

azure - Azure WebJobs SDK 是否支持将 TextWriter 日志推送到 App Insights 中?

Azure 无法创建 SendGrid 帐户,验证失败

WPF XAML StringFormat : Culture Workaround broken in C# 4. 0?

Azure管道重新运行失败的任务(不是整个阶段)

c# - 停止/取消正在运行的线程

c# - 在不考虑区域设置的情况下将日期插入 SQL

visual-studio-2010 - 如何在 C#.net 中为目标用户创建桌面路径

linq-to-sql - ASP.NET MVC 2 + LINQ to SQL - CS0012 编译错误