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
> 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.
20
+
> The bulk executor library described in this article is maintained for applications that use 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
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
@@ -43,13 +43,13 @@ Now let's switch to working with code by downloading a sample .NET application f
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).
@@ -105,29 +105,29 @@ The `BulkImportSample` application generates random documents and bulk imports t
105
105
106
106
|**Parameter**|**Description**|
107
107
|---------|---------|
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
-
|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 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
-
|cancellationToken | The cancellation token to gracefully exit the bulk import operation. |
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
+
|*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 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
+
|*cancellationToken*| The cancellation token to gracefully exit the bulk import operation. |
113
113
114
-
**Bulk import response object definition**
115
-
The result of the bulk import API call contains the following attributes:
114
+
**Bulk import response object definition**<br>
115
+
The result of the bulk import API call contains the following attributes:
116
116
117
117
|**Parameter**|**Description**|
118
118
|---------|---------|
119
-
|NumberOfDocumentsImported (long) | The total number of documents that were successfully imported out of the total documents supplied to the bulk import API call. |
120
-
|TotalRequestUnitsConsumed (double) | The total request units (RU) consumed by the bulk import API call. |
121
-
|TotalTimeTaken (TimeSpan) | The total time taken by the bulk import API call to complete the execution. |
122
-
|BadInputDocuments (List\<object>) | The list of bad-format documents that weren't successfully imported in the bulk import API call. Fix the documents returned and retry import. Bad-formatted documents include documents whose ID value isn't a string (null or any other datatype is considered invalid). |
119
+
|*NumberOfDocumentsImported* (long) | The total number of documents that were successfully imported out of the total documents supplied to the bulk import API call. |
120
+
|*TotalRequestUnitsConsumed* (double) | The total request units (RU) consumed by the bulk import API call. |
121
+
|*TotalTimeTaken* (TimeSpan) | The total time taken by the bulk import API call to complete the execution. |
122
+
|*BadInputDocuments* (List\<object>) | The list of bad-format documents that weren't successfully imported in the bulk import API call. Fix the documents returned and retry import. Bad-formatted documents include documents whose ID value isn't a string (null or any other datatype is considered invalid). |
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 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 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).
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 ex
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,26 +157,26 @@ You can update existing documents by using the `BulkUpdateAsync` API. In this ex
157
157
158
158
|**Parameter**|**Description**|
159
159
|---------|---------|
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
-
|cancellationToken|The cancellation token to gracefully exit the bulk update operation. |
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
+
|*cancellationToken*|The cancellation token to gracefully exit the bulk update operation. |
163
163
164
-
**Bulk update response object definition**
165
-
The result of the bulk update API call contains the following attributes:
164
+
**Bulk update response object definition**<br>
165
+
The result of the bulk update API call contains the following attributes:
166
166
167
167
|**Parameter**|**Description**|
168
168
|---------|---------|
169
-
|NumberOfDocumentsUpdated (long) | The number of documents that were successfully updated out of the total documents supplied to the bulk update API call. |
170
-
|TotalRequestUnitsConsumed (double) | The total request units (RUs) consumed by the bulk update API call. |
171
-
|TotalTimeTaken (TimeSpan) | The total time taken by the bulk update API call to complete the execution. |
169
+
|*NumberOfDocumentsUpdated* (long) | The number of documents that were successfully updated out of the total documents supplied to the bulk update API call. |
170
+
|*TotalRequestUnitsConsumed* (double) | The total request units (RUs) consumed by the bulk update API call. |
171
+
|*TotalTimeTaken* (TimeSpan) | The total time taken by the bulk update API call to complete the execution. |
172
172
173
173
## Performance tips
174
174
175
175
Consider the following points for better performance when you use the bulk executor library:
176
176
177
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
-
* 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.
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
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
@@ -188,7 +188,7 @@ Consider the following points for better performance when you use the bulk execu
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