本文介绍了获取一个StorageException(403:禁止)上CloudStorageContainer GetContainerReference方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我跑反对的Azure的存储模拟器单元测试以下code和接收StorageException当我尝试创建容器:
I'm running the following code in a unit test against Azure's Storage Emulator and receiving a StorageException when I attempt to create the container:
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服务假想运行的:
The Storage Emulator is running and the Blob service is supposedly running at:
http://127.0.0.1:10000/
唯一的例外是:
Microsoft.WindowsAzure.Storage.StorageException:远程服务器
返回了一个错误:(403)禁止
有什么想法?这是可能的从单元测试?
Any thoughts? Is this possible from a unit test?
推荐答案
请从改变你的连接字符串:
Please change your connection string from:
var connectionString = @"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
到
var connectionString = "UseDevelopmentStorage=true";
这应该照顾你面临的问题。
That should take care of the problem you're facing.
这篇关于获取一个StorageException(403:禁止)上CloudStorageContainer GetContainerReference方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!