Skip to content

Commit 8df7ed7

Browse files
authored
Merge pull request #112689 from ealsur/users/ealsur/bmigrupdate
Cosmos DB - Bulk executor library migration update
2 parents d1b0fac + a8bb264 commit 8df7ed7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

articles/cosmos-db/how-to-migrate-from-bulk-executor-library.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to migrate your application from using the bulk executor
44
author: ealsur
55
ms.service: cosmos-db
66
ms.topic: conceptual
7-
ms.date: 04/06/2020
7+
ms.date: 04/24/2020
88
ms.author: maquaran
99
---
1010

@@ -22,13 +22,13 @@ Enable bulk support on the `CosmosClient` instance through the [AllowBulkExecuti
2222

2323
Bulk support in the .NET SDK works by leveraging the [Task Parallel Library](https://docs.microsoft.com/dotnet/standard/parallel-programming/task-parallel-library-tpl) and grouping operations that occur concurrently.
2424

25-
There is no single method that will take your list of documents or operations as an input parameter, but rather, you need to create a Task for each operation you want to execute in bulk.
25+
There is no single method in the SDK that will take your list of documents or operations as an input parameter, but rather, you need to create a Task for each operation you want to execute in bulk, and then simply wait for them to complete.
2626

2727
For example, if your initial input is a list of items where each item has the following schema:
2828

2929
:::code language="csharp" source="~/samples-cosmosdb-dotnet-v3/Microsoft.Azure.Cosmos.Samples/Usage/BulkExecutorMigration/Program.cs" ID="Model":::
3030

31-
If you want to do bulk import (similar to using BulkExecutor.BulkImportAsync), you need to have concurrent calls to `CreateItemAsync` with each item value. For example:
31+
If you want to do bulk import (similar to using BulkExecutor.BulkImportAsync), you need to have concurrent calls to `CreateItemAsync`. For example:
3232

3333
:::code language="csharp" source="~/samples-cosmosdb-dotnet-v3/Microsoft.Azure.Cosmos.Samples/Usage/BulkExecutorMigration/Program.cs" ID="BulkImport":::
3434

@@ -42,7 +42,7 @@ And if you want to do bulk *delete* (similar to using [BulkExecutor.BulkDeleteAs
4242

4343
## Capture task result state
4444

45-
In the previous code examples, you have created a concurrent list of tasks, and called the `CaptureOperationResponse` method on each of those tasks. This method is an extension that lets us maintain a *similar response schema* as BulkExecutor, by capturing any errors and tracking the [request units usage](request-units.md).
45+
In the previous code examples, we have created a concurrent list of tasks, and called the `CaptureOperationResponse` method on each of those tasks. This method is an extension that lets us maintain a *similar response schema* as BulkExecutor, by capturing any errors and tracking the [request units usage](request-units.md).
4646

4747
:::code language="csharp" source="~/samples-cosmosdb-dotnet-v3/Microsoft.Azure.Cosmos.Samples/Usage/BulkExecutorMigration/Program.cs" ID="CaptureOperationResult":::
4848

@@ -52,7 +52,11 @@ Where the `OperationResponse` is declared as:
5252

5353
## Execute operations concurrently
5454

55-
After the list of tasks are defined, wait until they are all complete. You can track the completion of the tasks by defining the scope of your bulk operation as shown in the following code snippet:
55+
To track the scope of the entire list of Tasks, we use this helper class:
56+
57+
:::code language="csharp" source="~/samples-cosmosdb-dotnet-v3/Microsoft.Azure.Cosmos.Samples/Usage/BulkExecutorMigration/Program.cs" ID="BulkOperationsHelper":::
58+
59+
The `ExecuteAsync` method will wait until all operations are completed and you can use it like so:
5660

5761
:::code language="csharp" source="~/samples-cosmosdb-dotnet-v3/Microsoft.Azure.Cosmos.Samples/Usage/BulkExecutorMigration/Program.cs" ID="WhenAll":::
5862

0 commit comments

Comments
 (0)