Azure table storage error: "Unexpected response code to work: 99"

I got this error when I executed the following code:

var insert = new TableBatchOperation(); foreach (var entity in entities) { insert.Insert(entity); } cloudTable.ExecuteBatch(insert); 

If the collection of entities contained 512 elements. Azure SDK via StorageException:

 "Unexpected response code for operation : 99" 

What does this error mean, and how can I solve it?

+7
exception azure azure-table-storage
source share
2 answers

This ill-conceived error means that operations with an Azure array (at least in this case) take up to 100 elements . Limit your party and everything will be fine.

I ended up using something like this:

 public void Insert(IEnumerable<T> entities) { foreach (var chunk in entities.Chunk(100)) { InsertMaxLimitElements(chunk); } } private void InsertMaxLimitElements(IEnumerable<T> chunk) { var insert = new TableBatchOperation(); foreach (var entity in chunk) { insert.Insert(entity); } cloudTable.ExecuteBatch(insert); } 

The Chunk extension method was copied from this:

 public static IEnumerable<IEnumerable<T>> Chunk<T>(this IEnumerable<T> source, int chunksize) { while (source.Any()) { yield return source.Take(chunksize); source = source.Skip(chunksize); } } 
+18
source share

If the packet size is <100, this may also mean that you have duplicate records (two records with the same row key). This is very likely if it succeeds when you write recordings individually, but you cannot write in batch mode.

0
source share

All Articles