gpt4 book ai didi

azure - 获取存储异常 (403 : Forbidden) on CloudStorageContainer GetContainerReference method

转载 作者:行者123 更新时间:2023-12-04 14:02:04 26 4
gpt4 key购买 nike

我在针对 Azure 存储模拟器的单元测试中运行以下代码,并在尝试创建容器时收到 StorageException:

var connectionString = @"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
var account = CloudStorageAccount.Parse(connectionString);
var client = account.CreateCloudBlobClient();
var container = client.GetContainerReference("my-container");
container.CreateIfNotExists();

存储模拟器正在运行,并且 Blob 服务应该运行在:

http://127.0.0.1:10000/

异常(exception)情况是:

Microsoft.WindowsAzure.Storage.StorageException : The remote server returned an error: (403) Forbidden.

有什么想法吗?这可以通过单元测试实现吗?

最佳答案

请更改您的连接字符串:

var connectionString = @"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";

var connectionString = "UseDevelopmentStorage=true";

这应该可以解决您面临的问题。

关于azure - 获取存储异常 (403 : Forbidden) on CloudStorageContainer GetContainerReference method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17500433/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com