Microsoft.WindowsAzure.Storage.StorageException: Unexpected response code for operation ....
At times you would get errors such as below while executing batch transactions on a table in table storage
Microsoft.WindowsAzure.Storage.StorageException: Unexpected response code for operation : 5
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](StorageCommandBase`1 cmd, IRetryPolicy policy, OperationContext operationContext)
at Microsoft.WindowsAzure.Storage.Table.CloudTable.ExecuteBatch(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext)
at Worker.Processors.QueueOneProcessor.FlushCache()
Request Information
RequestID:fe0a42c7-faeb-4fd7-a9f8-690bc12e1f41
RequestDate:Tue, 21 May 2013 13:48:55 GMT
StatusMessage:Accepted
ErrorCode:OutOfRangeInput
One of the most common reason of such failure is malformed parameters passed in the query such as using disallowed characters in partitionkey or rowkey. The reason for the error above is that partitionkey contained a disallowed character "?". Refer to https://msdn.microsoft.com/en-us/library/dd179338.aspx which specifies below
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
If you are getting the aforementioned error then please check if the partitionkey or rowkey being passed contains a disallowed character and rectify it.
Comments
- Anonymous
August 31, 2013
wish the exception was better. eg "the character '/' is not allowed in a rowkey" - Anonymous
June 11, 2014
I think the reason I saw a similar error was that I was trying to update the same row twice in 1 batch. Fixing the code so each row is only updated once per batch resolved the error. - Anonymous
October 14, 2014
Seewww.neovolve.com/.../Azure-Table-Services-Unexpected-response-code-for-operation.aspx"In my scenario I had a null value pushed into a DateTime property" - Anonymous
November 26, 2014
Thank you! This is much more helpful than "Unexpected response code" error it gives back.