[英]Can't create azure blob container on storage emulator
從我的C#.NET代碼使用Azure存儲模擬器時,無法創建容器。
我在用:
var container = serviceClient.GetContainerReference("media");
container.CreateIfNotExists();`
它返回錯誤Error:
System.AggregateException:發生一個或多個錯誤。 ---> Microsoft.WindowsAzure.Storage.StorageException:遠程服務器返回錯誤:(403)禁止。 ---> System.Net.WebException:遠程服務器返回錯誤:(403)禁止。 在System.Net.HttpWebRequest.GetResponse()
添加以下行:
request.UseDefaultCredentials = true;
這將使應用程序使用登錄用戶的憑據來訪問站點。 如果返回403,則顯然是在等待身份驗證。
您(現在?)還可能在您和遠程站點之間具有身份驗證代理。 在這種情況下,請嘗試:
request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
您可以在app.config中為存儲模擬器設置一個連接字符串:
<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
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.