Azure Blob 400 创建容器时出现错误请求 [英] Azure Blob 400 Bad request on Creation of container

查看:38
本文介绍了Azure Blob 400 创建容器时出现错误请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 ASP.Net MVC 4 应用程序,我正在使用 Azure Blob 来存储我的用户要上传的图像.我有以下代码:

I'm developing an ASP.Net MVC 4 app and I'm using Azure Blob to store the images that my users are going to upload. I have the following code:

 var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnection"].ConnectionString);

 var blobStorage = storageAccount.CreateCloudBlobClient();
 //merchantKey is just a GUID that is asociated with the merchant
 var containerName = ("ImageAds-" + merchant.merchantKey.ToString()).ToLower();
 CloudBlobContainer container = blobStorage.GetContainerReference(containerName);
 if (container.CreateIfNotExist())
    {
       //Upload the file
    } 

一旦执行 if 语句,我就会收到以下异常:

as soon as the if statement is excecuted I'm getting the following exception:

  {"The remote server returned an error: (400) Bad Request."}

我以为这是容器的名称,但我看不出有什么问题.连接字符串似乎创建了一个很好的存储空间,其中包含 blob 的所有详细信息.我不知所措.我研究了网络,每个人都说这是一个命名问题,但我找不到任何问题.

I thought it was the container's name but I don't see anything wrong with it. The connection string seems to create a good storage with all details for the blob. I'm at a loss. I've researched the web and everyone is saying it's a naming problem but I can't find anything wrong with it.

我使用的测试容器名称:imageads-57905553-8585-4d7c-8270-be9e611eda81

Test Container name that I used: imageads-57905553-8585-4d7c-8270-be9e611eda81

容器具有以下 uri:{http://127.0.0.1:10000/devstoreaccount1/imageads-57905553-8585-4d7c-8270-be9e611eda81}

The Container has the following uri: {http://127.0.0.1:10000/devstoreaccount1/imageads-57905553-8585-4d7c-8270-be9e611eda81}

更新:我已将容器名称更改为 image,但仍然遇到相同的异常.还有开发连接字符串如下:<add name="StorageConnection" connectionString="UseDevelopmentStorage=true"/>

UPDATE: I have changed the container name to just image and I still get the same exception. also the development connection string is as follows: <add name="StorageConnection" connectionString="UseDevelopmentStorage=true" />

推荐答案

实际上我最终找到了问题所在.

I actually ended up finding the problem.

我的问题是 blob 存储模拟器无法启动(其他模拟器会启动而我错过了 blob).问题最终是端口 10000(默认 blob 模拟器端口)已被另一个软件使用.我使用 Netstat cmd 工具来查看它是哪个软件,杀死它,现在它像魅力一样工作!!!谢谢大家!!

My problem was that the blob storage emulator would not start (the other emulators would start and I missed the blob). The problem ended up being that the port 10000 (default blob emulator port) was already being used by another software. I used Netstat cmd tool to see which software it was, killed it and its now working like a charm!!! Thanks everyone!!

这篇关于Azure Blob 400 创建容器时出现错误请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆