Azure表存储错误:“操作的意外响应代码:99” [英] Azure table storage error: "Unexpected response code for operation : 99"
本文介绍了Azure表存储错误:“操作的意外响应代码: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);
其中实体集合包含512个元素。
通过StorageException的Azure SDK:
Where the entities collection contained 512 elements. The Azure SDK through a StorageException:
"Unexpected response code for operation : 99"
此错误是什么意思,我该如何解决?
What does this error mean, and how can I solve this?
推荐答案
此非描述性错误表示Azure批量操作(至少在这种情况下)最多包含100个元素。限制您的批次,您会变得很好。
This un-descriptive error means that Azure bulk operations (at least in this case) takes up to 100 elements. Limit your batch and you'll be good.
我最终使用了以下内容:
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);
}
块扩展方法是从此答案:
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);
}
}
这篇关于Azure表存储错误:“操作的意外响应代码:99”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文