windows Blob 容器创建异常

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2620521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:15:48  来源:igfitidea点击:

Blob container creation exception

windowsazureazure-storageazure-storage-blobs

提问by Egon

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

每次尝试为 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 ?

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

回答by user94559

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

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

回答by unconnected

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();

回答by Talon

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

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

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

您可以从这里获取最新的 SDK:https: //azure.microsoft.com/en-us/downloads/

回答by Simon Poulton

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:

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

  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.
  1. 像理查德一样,我在配置文件中的帐户名中有大写字母。
  2. 我在容器名称中有大写字母。
  3. 我在 blob 引用名称中有一个空格。

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.

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

回答by Richard

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!

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

回答by Jonas Stensved

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

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

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

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

After changing the name to lowercaseit worked perfectly.

将名称更改为小写后,它运行良好。

回答by David Makogon

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

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

回答by Jim W says reinstate Monica

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/

我的问题是模拟器实际上并没有启动,我没有意识到这一点。 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.

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

回答by Jorge Aguirre

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

Blob 引用只能有小写字符 - 也许您遇到了这个问题?我曾是。

回答by Eugenio Miró

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

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

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

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