Skip to content

Commit 8f163de

Browse files
committed
update
1 parent c74621f commit 8f163de

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -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+
After the list of tasks are defined, wait until they are all complete. 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="Operation":::
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)