// Create a new batch operation and add two insert operations var batchOperation = new TableBatchOperation(); batchOperation.Add(TableOperation.Insert(new MyEntity { PartitionKey = "pk", RowKey = "rk1", Property1 = "value1" })); batchOperation.Add(TableOperation.Insert(new MyEntity { PartitionKey = "pk", RowKey = "rk2", Property1 = "value2" })); // Execute the batch operation await table.ExecuteBatchAsync(batchOperation);
// Create a new batch operation and add a delete operation var batchOperation = new TableBatchOperation(); batchOperation.Add(TableOperation.Delete(new MyEntity { PartitionKey = "pk", RowKey = "rk1", ETag = "*" })); // Execute the batch operation await table.ExecuteBatchAsync(batchOperation);In this example, we create a new `TableBatchOperation` instance and add a `TableOperation.Delete` operation to it using the `Add` method. We set the `ETag` property to `"*"` to delete the entity regardless of its current ETag value. We then execute the batch operation using the `ExecuteBatchAsync` method of the `CloudTable` class. These examples use the `Microsoft.Azure.Cosmos.Table` package library.