One Cause of Azure Error – One of the request inputs is out of range

In making some innocuous seeming changes to working code in Windows Azure, I ran into an Exception when creating a Queue – and the cause was not at first obvious. The exception message was “One of the request inputs is out of range” and the inner exception message was “The remote server returned an error: (400) Bad Request.”

Illegal name causes “One of the request inputs is out of range”

Here is the code – why might this Windows Azure code snippet throw an Exception on the call to queue.CreateIfNotExist()?

CloudQueueClient queueStorage = storageAccount.CreateCloudQueueClient();
CloudQueue queue = queueStorage.GetQueueReference(“My Queue”);
bool queueJustCreated = queue.CreateIfNotExist();

The answer lies in the name we are using for the queue. Since the name is just a string, I assumed it can be any string. It cannot be any string.

Experimentation suggests the rules for naming a queue include: (a) use only lower case letters, (b) digits are allowed anywhere, and (c) internal single hyphens are okay too, but (d) name should not contain any spaces (e) nor any punctuation (other than hyphen).

So there would be no problem with valid names like:

  • myqueue
  • my-queue
  • myqueue-3

But there would be problems with illegal names like:

  • MyQueue
  • my queue
  • bill’squeue
  • -nogood
  • x-
  • not—quite
  • bad(name)

There may be additional nuances to the rules I didn’t discover, of course. One way to test out possible names quickly is with the myAzureStorage utility; just try to create a queue using the name and see if you get an error. Note that you can feed upper case chars to myAzureStorage but the created object will return with lower-case letter and will not cause an error.

Also, I only experimented with Queue names, but I assume the same rules apply to Blobs and Tables. Further research indicates this indeed is the case...

My challenge originally was to figure out why I got the Exception that was raised – that was the non-obvious part – the exception message did not tell me it was a problem with the name. After I figured it out and experimented a bit, of course then I found the documentation on allowed names which supports my conclusions… and adds details like length of name and the fact that the name is required to be a legal DNS name.

20 thoughts on “One Cause of Azure Error – One of the request inputs is out of range

  1. Pingback: Programming Windows Azure Blob Storage on One Page of Code « Coding Out Loud

  2. RobinDotNet

    Thank you, I just parameterized the queue name, and we set it to use an underscore in the same so we could distinguish between staging and production, and guess what — it doesn’t allow underscores. I never would have guessed that was the problem, so thanks for your post.

    Reply
    1. Bill Wilder Post author

      @RobinDotNet – glad it was useful. From my blog stats, I see this post getting many hits (mostly from search engines), but it is hard to know whether it is actually helping people solve a problem. Thanks for the comment.

      Reply
  3. GB

    Your assumptions were right, the only thing missing was the restriction on the name size. Queue naming rules can be found here: http://msdn.microsoft.com/en-us/library/dd179349.aspx. Basically:
    1. A queue name must start with a letter or number, and may contain only letters, numbers, and the dash (-) character.
    2. The first and last letters in the queue name must be alphanumeric. The dash (-) character may not be the first or last letter. Consecutive dash characters are not permitted in the queue name; every dash character must be immediately preceded and followed by a letter or number.
    3. All letters in a queue name must be lowercase.
    4. A queue name must be from 3 through 63 characters long.

    Thank you,

    GB

    Reply
  4. Simon Poulton

    Sorry Bill,
    I seem to be the first person for whom this hasn’t worked. I am trying to create a blob container and my code is falling over on .CreateIfNotexist(). Yes, I did have upper case letters in my name, but changing these (which, of course, matches the name in the Azure Portal) still didn’t solve the problem. Identical error!

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s