Blob容器创建异常
为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我的猜测是您使用的容器名称违反了命名规则。检查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.
我也有同样的例外。解决办法:将容器名称改为小写。
例外:
工作正常:
I've got the same exception. The solution: change container names to lower case.
With exception:
Works fine:
就我而言,模拟器已经过时了。停止模拟器并安装最新的 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/
这通常是由容器名称中包含大写字母或您的服务帐户名称(配置文件中的 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!
我得到了完全相同的错误。这是因为我在连接字符串中的帐户名是用大写字母编写的。
我什至无法通过 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.
我也花了几个小时试图解决这个问题 - 我认为理查德有权发表他的咆哮!
有很多关于容器名称不包含大写字符等的帖子。但是,我发现 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:
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.
根据您的代码片段,您似乎在初始化 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.
我的问题是模拟器实际上没有启动,而我没有意识到这一点。 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.
Blob 引用只能包含小写字符 - 也许您遇到了这种情况?我是。
Blob references can only have lowercase characters - perhaps you are running into this? I was.
就我而言,我发现存储模拟器应该更新,并且我意识到捕获
StorageException
异常并检查RequestInformation
属性,该属性又具有另一个名为HttpStatusMessage
。那条消息说:In my case, I found the Storage Emulator should be updated, and I realized about that catching
StorageException
exception and checking theRequestInformation
property which had, in turn, another string property namedHttpStatusMessage
. That message said: