Question

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 ?

Was it helpful?

Solution

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

OTHER TIPS

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

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/

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!

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.

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.

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

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 references can only have lowercase characters - perhaps you are running into this? I was.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top