I have method that submits batch transaction to table storage (Nuget: Azure.Data.Tables - 12.6.1).
Code below:
private static async Task BatchManipulateEntities<T>(TableClient tableClient, IEnumerable<T> entities, TableTransactionActionType tableTransactionActionType, int batchSize) where T : class, ITableEntity, new()
{
var groups = entities.GroupBy(x => new { x.PartitionKey });
foreach (var group in groups)
{
var items = group.AsEnumerable();
while (items.Any())
{
var batch = items.Take(batchSize);
items = items.Skip(batchSize);
var actions = batch.Select(e => new TableTransactionAction(tableTransactionActionType, e)).ToList();
await tableClient.SubmitTransactionAsync(actions); // <-- Will this count as one batch write operation?
}
}
}
这将调用最多100个TableTransactionActions的SubmitTransactionAsync. 但是,提交的批量交易是在幕后算作一个"批量写入操作",还是实际上是100个不同的操作?
Batch write operation is three times more costly than normal write operation, but if behind the scenes hundred entities will be uploaded as one batch write operation than I'm a happy man ;)
Azure Table Storage Pricing
如果有更聪明的人能澄清这一点,我将不胜感激!