You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> 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.
21
21
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.
23
23
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.
25
25
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).
* 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.
33
33
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).
35
35
36
36
* 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.
37
37
38
38
## Clone the sample application
39
39
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:
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.
47
47
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.
49
49
50
50
## <aid="bulk-import-data-to-an-azure-cosmos-account"></a>Bulk import data to an Azure Cosmos DB account
51
51
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.
53
53
54
54
1. The Azure Cosmos DB's connection strings are retrieved from the App.config file as shown in the following code:
55
55
@@ -63,7 +63,7 @@ The "BulkImportSample" application generates random documents and bulk imports t
63
63
64
64
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.
65
65
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:
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—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).
@@ -107,8 +107,8 @@ The "BulkImportSample" application generates random documents and bulk imports t
107
107
|---------|---------|
108
108
|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. |
109
109
|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). |
112
112
|cancellationToken | The cancellation token to gracefully exit the bulk import operation. |
113
113
114
114
**Bulk import response object definition**
@@ -123,11 +123,11 @@ The "BulkImportSample" application generates random documents and bulk imports t
123
123
124
124
## Bulk update data in your Azure Cosmos DB account
125
125
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).
127
127
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.
129
129
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).
@@ -144,7 +144,7 @@ You can update existing documents by using the BulkUpdateAsync API. In this exam
144
144
}
145
145
```
146
146
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).
@@ -157,8 +157,8 @@ You can update existing documents by using the BulkUpdateAsync API. In this exam
157
157
158
158
|**Parameter**|**Description**|
159
159
|---------|---------|
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). |
162
162
| cancellationToken|The cancellation token to gracefully exit the bulk update operation. |
163
163
164
164
**Bulk update response object definition**
@@ -172,13 +172,13 @@ You can update existing documents by using the BulkUpdateAsync API. In this exam
172
172
173
173
## Performance tips
174
174
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:
176
176
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.
178
178
179
179
* 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.
180
180
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.
182
182
183
183
* Ensure the `InitializeAsync()` method is invoked after instantiating a BulkExecutor object to fetch the target Azure Cosmos DB container's partition map.
184
184
@@ -188,7 +188,7 @@ Consider the following points for better performance when using the bulk executo
188
188
<gcServerenabled="true" />
189
189
</runtime>
190
190
```
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:
0 commit comments