Skip to content

Commit 8b74937

Browse files
committed
refresh and edits
1 parent 870c06b commit 8b74937

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

articles/cosmos-db/nosql/bulk-executor-dotnet.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Use bulk executor .NET library in Azure Cosmos DB for bulk import and update operations
3-
description: Bulk import and update the Azure Cosmos DB documents using the bulk executor .NET library.
3+
description: Learn how to bulk import and update the Azure Cosmos DB documents using the bulk executor .NET library.
44
author: abinav2307
55
ms.author: abramees
66
ms.service: cosmos-db
@@ -17,39 +17,39 @@ ms.custom: devx-track-csharp, ignite-2022
1717
[!INCLUDE[NoSQL](../includes/appliesto-nosql.md)]
1818

1919
> [!NOTE]
20-
> This bulk executor library described in this article is maintained for applications using the .NET SDK 2.x version. For new applications, you can use the **bulk support** that is directly available with the [.NET SDK version 3.x](tutorial-dotnet-bulk-import.md) and it does not require any external library.
20+
> The bulk executor library described in this article is maintained for applications using the .NET SDK 2.x version. For new applications, you can use the **bulk support** that's directly available with the [.NET SDK version 3.x](tutorial-dotnet-bulk-import.md), and it doesn't require any external library.
2121
22-
> If you are currently using the bulk executor library and planning to migrate to bulk support on the newer SDK, use the steps in the [Migration guide](how-to-migrate-from-bulk-executor-library.md) to migrate your application.
22+
> If you currently use the bulk executor library and plan to migrate to bulk support on the newer SDK, use the steps in the [Migration guide](how-to-migrate-from-bulk-executor-library.md) to migrate your application.
2323
24-
This tutorial provides instructions on using the bulk executor .NET library to import and update documents to an Azure Cosmos DB container. To learn about the bulk executor library and how it helps you use massive throughput and storage, see the [bulk executor library overview](../bulk-executor-overview.md) article. In this tutorial, you'll see a sample .NET application that bulk imports randomly generated documents into an Azure Cosmos DB container. After importing the data, the library shows you how you can bulk update the imported data by specifying patches as operations to perform on specific document fields.
24+
This tutorial provides instructions on how to use the bulk executor .NET library to import and update documents to an Azure Cosmos DB container. To learn about the bulk executor library and how it helps you use massive throughput and storage, see the [Azure Cosmos DB bulk executor library overview](../bulk-executor-overview.md). In this tutorial, you see a sample .NET application where bulk imports randomly generated documents into an Azure Cosmos DB container. After you import the data, the library shows you how you can bulk update the imported data by specifying patches as operations to perform on specific document fields.
2525

26-
Currently, bulk executor library is supported by the Azure Cosmos DB for NoSQL and API for Gremlin accounts only. This article describes how to use the bulk executor .NET library with API for NoSQL accounts. To learn about using the bulk executor .NET library with API for Gremlin accounts, see [perform bulk operations in the Azure Cosmos DB for Gremlin](../gremlin/bulk-executor-dotnet.md).
26+
Currently, bulk executor library is supported by the Azure Cosmos DB for NoSQL and API for Gremlin accounts only. This article describes how to use the bulk executor .NET library with API for NoSQL accounts. To learn how to use the bulk executor .NET library with API for Gremlin accounts, see [Ingest data in bulk in the Azure Cosmos DB for Gremlin by using a bulk executor library](../gremlin/bulk-executor-dotnet.md).
2727

2828
## Prerequisites
2929

3030
* Latest [!INCLUDE [cosmos-db-visual-studio](../includes/cosmos-db-visual-studio.md)]
3131

3232
* If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio) before you begin.
3333

34-
* You can [Try Azure Cosmos DB for free](https://azure.microsoft.com/try/cosmosdb/) without an Azure subscription, free of charge and commitments. Or, you can use the [Azure Cosmos DB Emulator](../local-emulator.md) with the `https://localhost:8081` endpoint. The Primary Key is provided in [Authenticating requests](../local-emulator.md#authenticate-requests).
34+
* You can [Try Azure Cosmos DB for free](https://azure.microsoft.com/try/cosmosdb/) without an Azure subscription. You can also use the [Azure Cosmos DB Emulator](../local-emulator.md) with the `https://localhost:8081` endpoint. The Primary Key is provided in [Authenticating requests](../local-emulator.md#authenticate-requests).
3535

3636
* Create an Azure Cosmos DB for NoSQL account by using the steps described in the [create a database account](quickstart-dotnet.md#create-account) section of the .NET quickstart article.
3737

3838
## Clone the sample application
3939

40-
Now let's switch to working with code by downloading a sample .NET application from GitHub. This application performs bulk operations on the data stored in your Azure Cosmos DB account. To clone the application, open a command prompt, navigate to the directory where you want to copy it and run the following command:
40+
Now let's switch to working with code by downloading a sample .NET application from GitHub. This application performs bulk operations on the data stored in your Azure Cosmos DB account. To clone the application, open a command prompt, navigate to the directory where you want to copy it, and run the following command:
4141

4242
```bash
4343
git clone https://github.com/Azure/azure-cosmosdb-bulkexecutor-dotnet-getting-started.git
4444
```
4545

46-
The cloned repository contains two samples "BulkImportSample" and "BulkUpdateSample". You can open either of the sample applications, update the connection strings in App.config file with your Azure Cosmos DB account's connection strings, build the solution, and run it.
46+
The cloned repository contains two samples, `BulkImportSample` and `BulkUpdateSample`. You can open either of the sample applications, update the connection strings in App.config file with your Azure Cosmos DB account's connection strings, build the solution, and run it.
4747

48-
The "BulkImportSample" application generates random documents and bulk imports them to your Azure Cosmos DB account. The "BulkUpdateSample" application bulk updates the imported documents by specifying patches as operations to perform on specific document fields. In the next sections, you'll review the code in each of these sample apps.
48+
The `BulkImportSample` application generates random documents and bulk imports them to your Azure Cosmos DB account. The `BulkUpdateSample` application bulk updates the imported documents by specifying patches as operations to perform on specific document fields. In the next sections, you'll review the code in each of these sample apps.
4949

5050
## <a id="bulk-import-data-to-an-azure-cosmos-account"></a>Bulk import data to an Azure Cosmos DB account
5151

52-
1. Navigate to the "BulkImportSample" folder and open the "BulkImportSample.sln" file.
52+
1. Navigate to the `BulkImportSample` folder and open the "BulkImportSample.sln" file.
5353

5454
1. The Azure Cosmos DB's connection strings are retrieved from the App.config file as shown in the following code:
5555

@@ -63,7 +63,7 @@ The "BulkImportSample" application generates random documents and bulk imports t
6363

6464
The bulk importer creates a new database and a container with the database name, container name, and the throughput values specified in the App.config file.
6565

66-
1. Next the DocumentClient object is initialized with Direct TCP connection mode:
66+
1. Next, the `DocumentClient` object is initialized with Direct TCP connection mode:
6767

6868
```csharp
6969
ConnectionPolicy connectionPolicy = new ConnectionPolicy
@@ -75,7 +75,7 @@ The "BulkImportSample" application generates random documents and bulk imports t
7575
connectionPolicy)
7676
```
7777

78-
1. The BulkExecutor object is initialized with a high retry value for wait time and throttled requests. And then they're set to 0 to pass congestion control to BulkExecutor for its lifetime.
78+
1. The `BulkExecutor` object is initialized with a high retry value for wait time and throttled requests. Then they're set to 0 to pass congestion control to `BulkExecutor` for its lifetime.
7979

8080
```csharp
8181
// Set retry options high during initialization (default values).
@@ -90,7 +90,7 @@ The "BulkImportSample" application generates random documents and bulk imports t
9090
client.ConnectionPolicy.RetryOptions.MaxRetryAttemptsOnThrottledRequests = 0;
9191
```
9292

93-
1. The application invokes the BulkImportAsync API. The .NET library provides two overloads of the bulk import API - one that accepts a list of serialized JSON documents and the other that accepts a list of deserialized POCO documents. To learn more about the definitions of each of these overloaded methods, refer to the [API documentation](/dotnet/api/microsoft.azure.cosmosdb.bulkexecutor.bulkexecutor.bulkimportasync).
93+
1. The application invokes the `BulkImportAsync` API. The .NET library provides two overloads of the bulk import API&mdash;one that accepts a list of serialized JSON documents and the other that accepts a list of deserialized POCO documents. To learn more about the definitions of each of these overloaded methods, refer to the [API documentation](/dotnet/api/microsoft.azure.cosmosdb.bulkexecutor.bulkexecutor.bulkimportasync).
9494

9595
```csharp
9696
BulkImportResponse bulkImportResponse = await bulkExecutor.BulkImportAsync(
@@ -107,8 +107,8 @@ The "BulkImportSample" application generates random documents and bulk imports t
107107
|---------|---------|
108108
|enableUpsert | A flag to enable upsert operations on the documents. If a document with the given ID already exists, it's updated. By default, it's set to false. |
109109
|disableAutomaticIdGeneration | A flag to disable automatic generation of ID. By default, it's set to true. |
110-
|maxConcurrencyPerPartitionKeyRange | The maximum degree of concurrency per partition key range, setting to null will cause library to use a default value of 20. |
111-
|maxInMemorySortingBatchSize | The maximum number of documents that are pulled from the document enumerator, which is passed to the API call in each stage. For in-memory sorting phase that happens before bulk importing, setting this parameter to null will cause library to use default minimum value (documents.count, 1000000). |
110+
|maxConcurrencyPerPartitionKeyRange | The maximum degree of concurrency per partition key range. Setting to null causes the library to use a default value of 20. |
111+
|maxInMemorySortingBatchSize | The maximum number of documents that are pulled from the document enumerator, which is passed to the API call in each stage. For the in-memory sorting phase that happens before bulk importing. Setting this parameter to null causes the library to use default minimum value (documents.count, 1000000). |
112112
|cancellationToken | The cancellation token to gracefully exit the bulk import operation. |
113113

114114
**Bulk import response object definition**
@@ -123,11 +123,11 @@ The "BulkImportSample" application generates random documents and bulk imports t
123123

124124
## Bulk update data in your Azure Cosmos DB account
125125

126-
You can update existing documents by using the BulkUpdateAsync API. In this example, you'll set the `Name` field to a new value and remove the `Description` field from the existing documents. For the full set of supported update operations, refer to the [API documentation](/dotnet/api/microsoft.azure.cosmosdb.bulkexecutor.bulkupdate).
126+
You can update existing documents by using the `BulkUpdateAsync` API. In this example, you set the `Name` field to a new value and remove the `Description` field from the existing documents. For the full set of supported update operations, refer to the [API documentation](/dotnet/api/microsoft.azure.cosmosdb.bulkexecutor.bulkupdate).
127127

128-
1. Navigate to the "BulkUpdateSample" folder and open the "BulkUpdateSample.sln" file.
128+
1. Navigate to the `BulkUpdateSample` folder and open the "BulkUpdateSample.sln" file.
129129

130-
1. Define the update items along with the corresponding field update operations. In this example, you'll use `SetUpdateOperation` to update the `Name` field and `UnsetUpdateOperation` to remove the `Description` field from all the documents. You can also perform other operations like increment a document field by a specific value, push specific values into an array field, or remove a specific value from an array field. To learn about different methods provided by the bulk update API, refer to the [API documentation](/dotnet/api/microsoft.azure.cosmosdb.bulkexecutor.bulkupdate).
130+
1. Define the update items along with the corresponding field update operations. In this example, you use `SetUpdateOperation` to update the `Name` field and `UnsetUpdateOperation` to remove the `Description` field from all the documents. You can also perform other operations like incrementing a document field by a specific value, pushing specific values into an array field, or removing a specific value from an array field. To learn about different methods provided by the bulk update API, refer to the [API documentation](/dotnet/api/microsoft.azure.cosmosdb.bulkexecutor.bulkupdate).
131131

132132
```csharp
133133
SetUpdateOperation<string> nameUpdate = new SetUpdateOperation<string>("Name", "UpdatedDoc");
@@ -144,7 +144,7 @@ You can update existing documents by using the BulkUpdateAsync API. In this exam
144144
}
145145
```
146146

147-
1. The application invokes the BulkUpdateAsync API. To learn about the definition of the BulkUpdateAsync method, refer to the [API documentation](/dotnet/api/microsoft.azure.cosmosdb.bulkexecutor.ibulkexecutor.bulkupdateasync).
147+
1. The application invokes the `BulkUpdateAsync` API. To learn about the definition of the `BulkUpdateAsync` method, refer to the [API documentation](/dotnet/api/microsoft.azure.cosmosdb.bulkexecutor.ibulkexecutor.bulkupdateasync).
148148

149149
```csharp
150150
BulkUpdateResponse bulkUpdateResponse = await bulkExecutor.BulkUpdateAsync(
@@ -157,8 +157,8 @@ You can update existing documents by using the BulkUpdateAsync API. In this exam
157157

158158
|**Parameter** |**Description** |
159159
|---------|---------|
160-
|maxConcurrencyPerPartitionKeyRange | The maximum degree of concurrency per partition key range, setting this parameter to null will make the library to use the default value(20). |
161-
|maxInMemorySortingBatchSize | The maximum number of update items pulled from the update items enumerator passed to the API call in each stage. For the in-memory sorting phase that happens before bulk updating, setting this parameter to null will cause the library to use the default minimum value(updateItems.count, 1000000). |
160+
|maxConcurrencyPerPartitionKeyRange | The maximum degree of concurrency per partition key range. Setting this parameter to null makes the library use the default value(20). |
161+
|maxInMemorySortingBatchSize | The maximum number of update items pulled from the update items enumerator passed to the API call in each stage. For the in-memory sorting phase that happens before bulk updating. Setting this parameter to null causes the library use the default minimum value(updateItems.count, 1000000). |
162162
| cancellationToken|The cancellation token to gracefully exit the bulk update operation. |
163163

164164
**Bulk update response object definition**
@@ -172,13 +172,13 @@ You can update existing documents by using the BulkUpdateAsync API. In this exam
172172

173173
## Performance tips
174174

175-
Consider the following points for better performance when using the bulk executor library:
175+
Consider the following points for better performance when you use the bulk executor library:
176176

177-
* For best performance, run your application from an Azure virtual machine that is in the same region as your Azure Cosmos DB account's write region.
177+
* For best performance, run your application from an Azure virtual machine that's in the same region as your Azure Cosmos DB account's write region.
178178

179179
* It's recommended that you instantiate a single `BulkExecutor` object for the whole application within a single virtual machine that corresponds to a specific Azure Cosmos DB container.
180180

181-
* A single bulk operation API execution consumes a large chunk of the client machine's CPU and network IO (This happens by spawning multiple tasks internally). Avoid spawning multiple concurrent tasks within your application process that execute bulk operation API calls. If a single bulk operation API call that is running on a single virtual machine is unable to consume the entire container's throughput (if your container's throughput > 1 million RU/s), it's preferred to create separate virtual machines to concurrently execute the bulk operation API calls.
181+
* A single bulk operation API execution consumes a large chunk of the client machine's CPU and network IO when spawning multiple tasks internally. Avoid spawning multiple concurrent tasks within your application process that execute bulk operation API calls. If a single bulk operation API call that's running on a single virtual machine is unable to consume the entire container's throughput (if your container's throughput > 1 million RU/s), it's preferred to create separate virtual machines to concurrently execute the bulk operation API calls.
182182

183183
* Ensure the `InitializeAsync()` method is invoked after instantiating a BulkExecutor object to fetch the target Azure Cosmos DB container's partition map.
184184

@@ -188,7 +188,7 @@ Consider the following points for better performance when using the bulk executo
188188
<gcServer enabled="true" />
189189
</runtime>
190190
```
191-
* The library emits traces that can be collected either into a log file or on the console. To enable both, add the following code to your application's App.Config file.
191+
* The library emits traces that can be collected either into a log file or on the console. To enable both, add the following code to your application's App.Config file:
192192

193193
```xml
194194
<system.diagnostics>

0 commit comments

Comments
 (0)