I have a azure function app which will generate multiple entries based on one partition key. In case any error during the function execution. I first delete all entities on my azure table which have the same partition key, in case the function get retries 2nd or 3nd times and insert duplicated records.
So I decided to use ExcuteBatch operation by looping through a set of 100s entities.
I not sure what the TableBatch will return. Does it return all success deletion result?
This is what i have written at this stage.
var projectionQuery = new TableQuery()
.Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "partitionKey"))
.Select(new[] { "RowKey" });
var entities = table.ExecuteQuery(projectionQuery).ToList();
var offset = 0;
while (offset < entities.Count)
{
var batch = new TableBatchOperation();
var rows = entities.Skip(offset).Take(100).ToList();
foreach (var row in rows)
{
batch.Delete(row);
}
var result = table.ExecuteBatch(batch);
offset += result.Where(x=>x.HttpStatusCode == (int) HttpStatusCode.NoContent).Count() + offset;
}
If the above code is correct. Will there be an infinite loop where the data which tried to delete could not be deleted and it keep tried to delete.