繁体   English   中英

无法在Azure Blob存储上创建Blob容器

[英]Can't create blob container on Azure Blob Storage

以下代码在“ CreateIfNotExist”方法调用上引发错误。 我正在尝试连接到我的Azure Blob存储并创建一个名为“ images”的新容器

var storageAccount = new CloudStorageAccount(
    new StorageCredentialsAccountAndKey("my_account_name", "my shared key"),
    "https://blob.core.windows.net/",
    "https://queue.core.windows.net/",
    "https://table.core.windows.net/"
);
var blobClient = storageAccount.CreateCloudBlobClient();
var blobContainer = blobClient.GetContainerReference("images");
blobContainer.CreateIfNotExist();

错误是:

[StorageClientException: The requested URI does not represent any resource on the server.]

“图像”容器不存在,但是我期望它可以创建而不是引发错误。 我究竟做错了什么?

我尝试使用HTTP而不是HTTPS,但是结果是相同的错误。

我发现我必须使用其他语法

var storageAccount = new CloudStorageAccount(
   new StorageCredentialsAccountAndKey("my_account_name", "my shared key"));
var blobClient = storageAccount.CreateCloudBlobClient(); 
var blobContainer = blobClient.GetContainerReference("images"); 
blobContainer.CreateIfNotExists(); 

注意如何省略端点。 显然,CloudBlobClient可以自动找出适当的URI。

您确定帐户名和共享密钥正确吗? 您可以尝试安装Fiddler来查看HTTP流量,以确保那里没有可疑的东西。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM