Azure table storage returns 400 Bad Request Azure table storage returns 400 Bad Request azure azure

Azure table storage returns 400 Bad Request


400 Error means there's something wrong with the value of one of your properties. One way to find out is to trace the request/response through Fiddler and see the actual data being sent to Windows Azure Storage.

Taking a wild guess, I'm assuming by taking a quick glance at your code that in your model you have some Date/Time type properties (OfflineTimestamp, OnlineTimestamp) and observed that in certain scenarios one of them is initialized with the default value which is "DateTime.MinValue". Please note that the minimum value allowed for a Date/Time type attribute is Jan 1, 1601 (UTC) in Windows Azure[http://msdn.microsoft.com/en-us/library/windowsazure/dd179338.aspx]. Please see if that's not the case. If that's the case, then you could make them nullable type fields so that they don't get populated with the default values.

Have a look at Juha Palomäki's answer below as well... there sometimes is a slightly more useful message in the exception where he suggests (RequestInformation.ExtendedErrorInformation.ErrorMessage)


The StorageException contains also a little bit more detailed information about error.

Check in debugger: StorageException.RequestInformation.ExtendedInformation

enter image description here


In my case it was a forward slash in the RowKey.

I also received an 'OutOfRangeInput - One of the request inputs is out of range.' error when trying to add manually through the storage emulator.

Characters Disallowed in Key Fields

The following characters are not allowed in values for the PartitionKey and RowKey properties:

  • The forward slash (/) character
  • The backslash (\) character
  • The number sign (#) character
  • The question mark (?) character
  • Control characters from U+0000 to U+001F, including:
    • The horizontal tab (\t) character
    • The linefeed (\n) character
    • The carriage return (\r) character
    • Control characters from U+007F to U+009F

http://msdn.microsoft.com/en-us/library/dd179338.aspx

I wrote an extension method to handle this for me.

public static string ToAzureKeyString(this string str){    var sb = new StringBuilder();    foreach (var c in str        .Where(c => c != '/'                    && c != '\\'                    && c != '#'                    && c != '/'                    && c != '?'                    && !char.IsControl(c)))        sb.Append(c);    return sb.ToString();}