Home > Enterprise >  Container delete items async for large quantities of id
Container delete items async for large quantities of id

Time:03-15

I'm fairly new to cosmos db, and I have a function that deletes the entries of a record. Currently I'm using this method "container.DeleteItemsAsync". It is working, but the problem is, whenever I try to delete thousands of ids, I received a time out. Is there a method that supports batch deletion?

CodePudding user response:

Have you enabled Bulk mode and try deleting the documents? It should work the same way for Create

 _client = new CosmosClient(connectionString, new CosmosClientOptions() { AllowBulkExecution = true });

// Delete item with 'id':
var partitionKey = new PartitionKey(id);
tasks.Add(_devicesContainer.DeleteItemStreamAsync(id, partitionKey));

// Wait processing to finish
await Task.WhenAll(tasks);
  • Related