【问题标题】:Can't create azure blob container on storage emulator无法在存储模拟器上创建 azure blob 容器
【发布时间】:2018-11-21 10:43:45
【问题描述】:

在我的 c# .NET 代码中使用 Azure 存储模拟器时,我无法创建容器。

我正在使用:

var container = serviceClient.GetContainerReference("media");
container.CreateIfNotExists();`

它返回错误错误:

System.AggregateException:发生一个或多个错误。 ---> Microsoft.WindowsAzure.Storage.StorageException:远程服务器返回错误:(403)禁止。 ---> System.Net.WebException:远程服务器返回错误:(403)禁止。 在 System.Net.HttpWebRequest.GetResponse()

【问题讨论】:

  • 你的连接字符串是什么?
  • 看看this是否有帮助。
  • 是的,这行得通!我只使用了帐户名和键值。谢谢:D

标签: azure azure-storage azure-blob-storage azure-storage-emulator


【解决方案1】:

添加以下行:

request.UseDefaultCredentials = true;

这将使应用程序使用登录用户的凭据来访问该站点。如果它返回 403,显然它正在等待身份验证。

您(现在?)也有可能在您和远程站点之间有一个身份验证代理。在这种情况下,请尝试:

request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

您可以在 app.config 中为storage emulator 设置连接字符串:

<appSettings>
  <add key="StorageConnectionString" value="UseDevelopmentStorage=true" />
</appSettings>

如果您想使用帐户名和密钥连接到存储模拟器,则需要提供其他详细信息,例如不同的端点。

var connectionString = @"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;
AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;
    BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;
    TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;
    QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;";

此值与上面显示的快捷方式相同,UseDevelopmentStorage=true

【讨论】:

  • 是的,它正在处理其他详细信息。谢谢! :)
猜你喜欢
  • 2011-02-24
  • 2015-04-01
  • 2013-02-23
  • 2013-06-01
  • 2020-05-20
  • 2021-06-11
  • 2018-09-30
  • 2013-08-18
  • 2015-04-24
相关资源
最近更新 更多