Blob容器创建异常

发布于 2024-08-28 21:41:13 字数 2497 浏览 7 评论 0原文

为 blob 创建容器时都会出现异常

每次我尝试使用以下代码


CloudStorageAccount storageAccInfo;
CloudBlobClient blobStorageType;
CloudBlobContainer ContBlob;

blobStorageType = storageAccInfo.CreateCloudBlobClient();

//then I initialize storageAccInfo

ContBlob = blobStorageType.GetContainerReference(containerName);
//everything fine till here ; next line creates an exception

ContBlob.CreateIfNotExist();

Microsoft.WindowsAzure.StorageClient.StorageClientException was unhandled
  Message="One of the request inputs is out of range."
  Source="Microsoft.WindowsAzure.StorageClient"
  StackTrace:
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
       at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImplWithRetry[T](Func`2 impl, RetryPolicy policy)
       at Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.CreateIfNotExist(BlobRequestOptions options)
       at Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.CreateIfNotExist()
       at WebRole1.BlobFun..ctor() in C:\Users\cloud\Documents\Visual Studio 2008\Projects\CloudBlob\WebRole1\BlobFun.cs:line 58
       at WebRole1.BlobFun.calling1() in C:\Users\cloud\Documents\Visual Studio 2008\Projects\CloudBlob\WebRole1\BlobFun.cs:line 29
       at AzureBlobTester.Program.Main(String[] args) in C:\Users\cloud\Documents\Visual Studio 2008\Projects\CloudBlob\AzureBlobTester\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Net.WebException
       Message="The remote server returned an error: (400) Bad Request."
       Source="System"
       StackTrace:
            at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
            at Microsoft.WindowsAzure.StorageClient.EventHelper.ProcessWebResponse(WebRequest req, IAsyncResult asyncResult, EventHandler`1 handler, Object sender)
       InnerException: 

你们知道我做错了什么吗?

I get an exception every time I try to create a container for the blob

using the following code


CloudStorageAccount storageAccInfo;
CloudBlobClient blobStorageType;
CloudBlobContainer ContBlob;

blobStorageType = storageAccInfo.CreateCloudBlobClient();

//then I initialize storageAccInfo

ContBlob = blobStorageType.GetContainerReference(containerName);
//everything fine till here ; next line creates an exception

ContBlob.CreateIfNotExist();

Microsoft.WindowsAzure.StorageClient.StorageClientException was unhandled
  Message="One of the request inputs is out of range."
  Source="Microsoft.WindowsAzure.StorageClient"
  StackTrace:
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
       at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImplWithRetry[T](Func`2 impl, RetryPolicy policy)
       at Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.CreateIfNotExist(BlobRequestOptions options)
       at Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.CreateIfNotExist()
       at WebRole1.BlobFun..ctor() in C:\Users\cloud\Documents\Visual Studio 2008\Projects\CloudBlob\WebRole1\BlobFun.cs:line 58
       at WebRole1.BlobFun.calling1() in C:\Users\cloud\Documents\Visual Studio 2008\Projects\CloudBlob\WebRole1\BlobFun.cs:line 29
       at AzureBlobTester.Program.Main(String[] args) in C:\Users\cloud\Documents\Visual Studio 2008\Projects\CloudBlob\AzureBlobTester\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Net.WebException
       Message="The remote server returned an error: (400) Bad Request."
       Source="System"
       StackTrace:
            at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
            at Microsoft.WindowsAzure.StorageClient.EventHelper.ProcessWebResponse(WebRequest req, IAsyncResult asyncResult, EventHandler`1 handler, Object sender)
       InnerException: 

Do you guys knw what is it that I am doing wrong ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

等风来 2024-09-04 21:41:13

我的猜测是您使用的容器名称违反了命名规则。检查http://msdn.microsoft.com/en-us/library/dd135715。 .aspx.

My guess is that the container name you're using violates the naming rules. Check http://msdn.microsoft.com/en-us/library/dd135715.aspx.

蓝戈者 2024-09-04 21:41:13

我也有同样的例外。解决办法:将容器名称改为小写。

例外:

CloudBlobContainer container = blobClient.GetContainerReference("Script");
container.CreateIfNotExist();

工作正常:

CloudBlobContainer container = blobClient.GetContainerReference("script");
container.CreateIfNotExist();

I've got the same exception. The solution: change container names to lower case.

With exception:

CloudBlobContainer container = blobClient.GetContainerReference("Script");
container.CreateIfNotExist();

Works fine:

CloudBlobContainer container = blobClient.GetContainerReference("script");
container.CreateIfNotExist();
悲念泪 2024-09-04 21:41:13

就我而言,模拟器已经过时了。停止模拟器并安装最新的 SDK 后,问题就消失了。

您可以从此处获取最新的 SDK:https://azure.microsoft.com/en-us /下载/

In my case, the emulator was out of date. After stopping the emulator and installing the latest SDK the problem went away.

You can get the latest SDK from here: https://azure.microsoft.com/en-us/downloads/

诗化ㄋ丶相逢 2024-09-04 21:41:13

这通常是由容器名称中包含大写字母或您的服务帐户名称(配置文件中的 AccountName=)包含大写字母引起的。这太蹩脚了。有人可以告诉 Microsoft 这些是 101 种反模式吗? Azure 控制台环境允许您输入帐户名称,例如“LameDuck”,但您必须使用 AccountName=lameduck 进行连接,否则它会在您面前弹出难以理解的错误消息。当你在 Azure 控制台中输入 LameDuck 时,它甚至不会警告你,如果你准确地使用这个名称,它会在你面前爆炸。这是浪费我们的时间,因为我们至少期望一致的反模式——期望太多了?如果您不允许使用大写字母进行连接,则不允许在 Azure 控制台中使用大写字母名称创建帐户!但现在你应该能够处理大写字母了。哎呀!

This is often caused by either a container name with upper case letters in it, or your service account name (AccountName= in the config file) contains upper case letters. This is SO lame. Can somebody tell Microsoft that these are 101 anti-patterns. The Azure console environment permits you to enter an account name, "LameDuck" for example, but you have to connect with AccountName=lameduck, or it blows up in your face with an unintelligible error message. When you enter LameDuck in the Azure console, it does not even warn you that it will blow up in your face if you use precisely this name. This is a waste of OUR time, since we at least expect consistent anti-patterns -- too much to expect? If you don't allow connections with upper case, then don't allow the accounts to be created with upper case names in the Azure console! But you should be able to handle upper case these days. Jeees!

不…忘初心 2024-09-04 21:41:13

我得到了完全相同的错误。这是因为我在连接字符串中的帐户名是用大写字母编写的。

我什至无法通过 Visual Studio 中的服务器资源管理器进行连接。

将名称更改为小写后,效果非常好。

I got the exact same error. It was due to my account name in the connectionstring was written with uppercase letters.

I couldn't even connect through then Server Explorer in Visual Studio.

After changing the name to lowercase it worked perfectly.

も星光 2024-09-04 21:41:13

我也花了几个小时试图解决这个问题 - 我认为理查德有权发表他的咆哮!

有很多关于容器名称不包含大写字符等的帖子。但是,我发现 blob 引用名称也必须符合。事实上,我有三个违规行为:

  1. 像理查德一样,我在配置文件中的帐户名中使用了大写字母。
  2. 我的容器名称中有大写字母。
  3. 我的 blob 引用名称中有一个空格。

如果错误消息毫无意义,则很难追踪这些复合错误。问题是错误是在完全相同的代码行处引发的,即使原因可能不同。

I too have spent hours trying to sort out this problem - I think Richard is entitled to his rant!

There are many posts about the name for containers not having upper-case characters, etc. However, I have found that the blob reference name must also comply. In fact, I had three violations:

  1. Like Richard I had upper case letters in my account name in the config file.
  2. I had upper case letters in the container name.
  3. I had a space in the blob reference name.

These compound errors are very difficult to track down if the error messages are meaningless. The problem is that the error is thrown at exactly the same line of code, even though the causes may be different.

↘紸啶 2024-09-04 21:41:13

根据您的代码片段,您似乎在初始化 storageAccInfo 之前调用 CreateBlobClient() 。我想这会给你带来麻烦。

Based on your code snippet, it looks like you're calling CreateBlobClient() prior to initializing storageAccInfo. I'd imagine this would cause you trouble.

柠檬 2024-09-04 21:41:13

我的问题是模拟器实际上没有启动,而我没有意识到这一点。 http://mhuensch.azurewebsites.net/azure-storage-wont-start/

它没有启动,因为模拟器使用端口 10000 并且与该端口存在冲突。

My problem was that the emulator was not actually starting up and I hadn't realized that. http://mhuensch.azurewebsites.net/azure-storage-wont-start/

It wasn't starting because the emulator uses port 10000 and there was a conflict with that port.

相守太难 2024-09-04 21:41:13

Blob 引用只能包含小写字符 - 也许您遇到了这种情况?我是。

Blob references can only have lowercase characters - perhaps you are running into this? I was.

墟烟 2024-09-04 21:41:13

就我而言,我发现存储模拟器应该更新,并且我意识到捕获 StorageException 异常并检查 RequestInformation 属性,该属性又具有另一个名为HttpStatusMessage。那条消息说:

此版本的存储模拟器不支持此请求的 REST 版本。请将存储模拟器升级到最新版本。有关详细信息,请参阅以下 URL: http://go.microsoft.com/fwlink/ ?LinkId=392237

In my case, I found the Storage Emulator should be updated, and I realized about that catching StorageException exception and checking the RequestInformation property which had, in turn, another string property named HttpStatusMessage. That message said:

The REST version of this request is not supported by this release of the Storage Emulator. Please upgrade the storage emulator to the latest version. Refer to the following URL for more information: http://go.microsoft.com/fwlink/?LinkId=392237

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文