Friday, March 7, 2014

OutOfRangeInput Error in Azure

I’m fairly new to Azure programming. Maybe this is obvious to everyone out there, but it wasn’t obvious to me, so I figured I’d record it on my blog for all you newbies out there like me.

I have been working on a simple application that stores data in a table in Azure. Because I am new to Azure table storage, I followed a few online tutorials to get started. Here is one of the ones I read.

http://www.windowsazure.com/en-us/documentation/articles/storage-dotnet-how-to-use-table-storage-20/

I made a few basic changes to my code rather than copying it word for word. When I tried to run my app, I kept getting a

StorageException - The remote server returned an error: (400) Bad Request.

every time I tried to insert a new row in the table. The samples were so simple and I thought I followed them closely. I spent a couple of hours trying to figure out what was going on, and I finally stumbled upon the answer. This took WAY TOO MUCH time to figure out, so I hope this helps you out in your development.

So here is the deal…

When I created my entity that I was going to insert, I had a DateTime.Now.ToString as part of the row key in the entity. It turns out you can’t use that in partition keys or row keys. When you are running on Azure, the format for the date is “YYYY/MM/DD”. The ‘/’ character is not permitted in row keys or partition keys.

Once I removed that, everything worked smoothly.

It was a simple error, but like I said before, it took way too long to figure out.

Happy Coding Folks!

1 comment: