简体   繁体   English

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

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

The following code throws an error on the "CreateIfNotExist" method call. 以下代码在“ CreateIfNotExist”方法调用上引发错误。 I am attempting to connect to my Azure Blob storage and create a new container called "images" 我正在尝试连接到我的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();

The error is: 错误是:

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

The "images" container does not exist but I was expecting it to be created instead of an error to be thrown. “图像”容器不存在,但是我期望它可以创建而不是引发错误。 What am I doing wrong? 我究竟做错了什么?

I have tried HTTP instead of HTTPS but the result is the same error. 我尝试使用HTTP而不是HTTPS,但是结果是相同的错误。

I have figured out that I must use a different syntax 我发现我必须使用其他语法

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

Notice how the end points are omited. 注意如何省略端点。 Evidently, the CloudBlobClient can figure out the appropriate URIs automatically. 显然,CloudBlobClient可以自动找出适当的URI。

Are you sure the account name and shared key are correct? 您确定帐户名和共享密钥正确吗? You might try installing Fiddler to take a look at the HTTP traffic to make sure nothing there looks suspicious. 您可以尝试安装Fiddler来查看HTTP流量,以确保那里没有可疑的东西。

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

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