Skip to content

Commit b6dffe6

Browse files
committed
Updating code snippet format
1 parent 8068717 commit b6dffe6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

articles/cosmos-db/sql-api-nodejs-get-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Now that your app exists, you need to make sure it can talk to Azure Cosmos DB.
9090

9191
1. Copy and paste the ```database```, ```container```, and ```items``` data to your ```config``` object below where you set your ```config.endpoint``` and ```config.key``` properties. If you already have data you'd like to store in your database, you can use the Data Migration tool in Azure Cosmos DB rather than defining the data here. You config.js file should have the following code:
9292

93-
[!code-javascript[nodejs-get-started](~/cosmosdb-nodejs-get-started/config.js)]
93+
:::code language="csharp" source="~/cosmosdb-nodejs-get-started/config.js":::
9494

9595
JavaScript SDK uses the generic terms *container* and *item*. A container can be a collection, graph, or table. An item can be a document, edge/vertex, or row, and is the content inside a container.
9696

@@ -597,7 +597,7 @@ Deleting the created database will remove the database and all children resource
597597

598598
Altogether, your code should look like this:
599599

600-
[!code-javascript[nodejs-get-started](~/cosmosdb-nodejs-get-started/app.js)]
600+
:::code language="csharp" source="~/cosmosdb-nodejs-get-started/app.js":::
601601

602602
In your terminal, locate your ```app.js``` file and run the command:
603603

articles/cosmos-db/tutorial-sql-api-dotnet-bulk-import.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ Let's start by overwriting the default `Main` method and defining the global var
115115

116116
Inside the `Main` method, add the following code to initialize the CosmosClient object:
117117

118-
[!code-csharp[Main](~/cosmos-dotnet-bulk-import/src/Program.cs?name=CreateClient)]
118+
:::code language="csharp" source="~/cosmos-dotnet-bulk-import/src/Program.cs" id="CreateClient":::
119119

120120
After the bulk execution is enabled, the CosmosClient internally groups concurrent operations into single service calls. This way it optimizes the throughput utilization by distributing service calls across partitions, and finally assigning individual results to the original callers.
121121

122122
You can then create a container to store all our items. Define `/pk` as the partition key, 50000 RU/s as provisioned throughput, and a custom indexing policy that will exclude all fields to optimize the write throughput. Add the following code after the CosmosClient initialization statement:
123123

124-
[!code-csharp[Main](~/cosmos-dotnet-bulk-import/src/Program.cs?name=Initialize)]
124+
:::code language="csharp" source="~/cosmos-dotnet-bulk-import/src/Program.cs" id="Initialize":::
125125

126126
## Step 6: Populate a list of concurrent tasks
127127

@@ -136,22 +136,22 @@ First, add the Bogus package to the solution by using the dotnet add package com
136136

137137
Define the definition of the items that you want to save. You need to define the `Item` class within the `Program.cs` file:
138138

139-
[!code-csharp[Main](~/cosmos-dotnet-bulk-import/src/Program.cs?name=Model)]
139+
:::code language="csharp" source="~/cosmos-dotnet-bulk-import/src/Program.cs" id="Model":::
140140

141141
Next, create a helper function inside the `Program` class. This helper function will get the number of items you defined to insert and generates random data:
142142

143-
[!code-csharp[Main](~/cosmos-dotnet-bulk-import/src/Program.cs?name=Bogus)]
143+
:::code language="csharp" source="~/cosmos-dotnet-bulk-import/src/Program.cs" id="Bogus":::
144144

145145
Read the items and serialize them into stream instances by using the `System.Text.Json` class. Because of the nature of the autogenerated data, you are serializing the data as streams. You can also use the item instance directly, but by converting them to streams, you can leverage the performance of stream APIs in the CosmosClient. Typically you can use the data directly as long as you know the partition key.
146146

147147

148148
To convert the data to stream instances, within the `Main` method, add the following code right after creating the container:
149149

150-
[!code-csharp[Main](~/cosmos-dotnet-bulk-import/src/Program.cs?name=Operations)]
150+
:::code language="csharp" source="~/cosmos-dotnet-bulk-import/src/Program.cs" id="Operations":::
151151

152152
Next use the data streams to create concurrent tasks and populate the task list to insert the items into the container. To perform this operation, add the following code to the `Program` class:
153153

154-
[!code-csharp[Main](~/cosmos-dotnet-bulk-import/src/Program.cs?name=ConcurrentTasks)]
154+
:::code language="csharp" source="~/cosmos-dotnet-bulk-import/src/Program.cs" id="ConcurrentTasks":::
155155

156156
All these concurrent point operations will be executed together (that is in bulk) as described in the introduction section.
157157

0 commit comments

Comments
 (0)