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
[!INCLUDE[Console app language selector](includes/tutorial-console-app-selector.md)]
21
21
22
-
The Azure SDK for .NET allows you to add data to an API for NoSQL container either [asynchronous individual operations](how-to-dotnet-create-item.md#create-an-item-asynchronously) or a [transactional batch](transactional-batch.md?tabs=dotnet). This tutorial will walk through the process of create a new .NET console application that adds multiple items to a container.
22
+
The Azure SDK for .NET allows you to add data to an API for NoSQL container either [asynchronous individual operations](how-to-dotnet-create-item.md#create-an-item-asynchronously) or a [transactional batch](transactional-batch.md?tabs=dotnet). This tutorial walks through the process of create a new .NET console application that adds multiple items to a container.
23
23
24
24
In this tutorial, you learn how to:
25
25
@@ -38,20 +38,20 @@ In this tutorial, you learn how to:
38
38
- If you have an existing Azure subscription, [create a new account](how-to-create-account.md?tabs=azure-portal).
39
39
- No Azure subscription? You can [try Azure Cosmos DB free](../try-free.md) with no credit card required.
40
40
-[Visual Studio Code](https://code.visualstudio.com)
41
-
-[.NET 6 (LTS) or later](https://dotnet.microsoft.com/download/dotnet/6.0)
41
+
-[.NET 8 or later](https://dotnet.microsoft.com/download/dotnet/8.0)
42
42
- Experience writing C# applications.
43
43
44
44
## Create API for NoSQL resources
45
45
46
-
First, create an empty database in the existing API for NoSQL account. You'll create a container using the Azure SDK for .NET later.
46
+
First, create an empty database in the existing API for NoSQL account. You create a container using the Azure SDK for .NET later.
47
47
48
48
1. Navigate to your existing API for NoSQL account in the [Azure portal](https://portal.azure.com/).
49
49
50
50
1. In the resource menu, select **Keys**.
51
51
52
52
:::image type="content" source="media/tutorial-dotnet-console-app/resource-menu-keys.png" lightbox="media/tutorial-dotnet-console-app/resource-menu-keys.png" alt-text="Screenshot of an API for NoSQL account page. The Keys option is highlighted in the resource menu.":::
53
53
54
-
1. On the **Keys** page, observe and record the value of the **URI** and **PRIMARY KEY** fields. These values will be used throughout the tutorial.
54
+
1. On the **Keys** page, observe and record the value of the **URI** and **PRIMARY KEY** fields. These values are used throughout the tutorial.
55
55
56
56
:::image type="content" source="media/tutorial-dotnet-console-app/page-keys.png" alt-text="Screenshot of the Keys page with the URI and Primary Key fields highlighted.":::
57
57
@@ -77,7 +77,7 @@ First, create an empty database in the existing API for NoSQL account. You'll cr
77
77
78
78
## Create .NET console application
79
79
80
-
Now, you'll create a new .NET console application and import the Azure SDK for .NET by using the `Microsoft.Azure.Cosmos` library from NuGet.
80
+
Now, you create a new .NET console application and import the Azure SDK for .NET by using the `Microsoft.Azure.Cosmos` library from NuGet.
81
81
82
82
1. Open a terminal in an empty directory.
83
83
@@ -155,7 +155,7 @@ Now, you'll create a new .NET console application and import the Azure SDK for .
155
155
156
156
## Add items to a container using the SDK
157
157
158
-
Next, you'll use individual operations to add items into the API for NoSQL container. In this section, you'll define the `CosmosHandler.ManageCustomerAsync` method.
158
+
Next, you use individual operations to add items into the API for NoSQL container. In this section, you define the `CosmosHandler.ManageCustomerAsync` method.
159
159
160
160
1. Create a new **CosmosHandler.cs** file.
161
161
@@ -173,7 +173,7 @@ Next, you'll use individual operations to add items into the API for NoSQL conta
173
173
{ }
174
174
```
175
175
176
-
1. Just to validate this app will work, create a short implementation of the static `ManageCustomerAsync` method to print the command-line input.
176
+
1. Just to validate this app works, create a short implementation of the static `ManageCustomerAsync` method to print the command-line input.
1. This time, the program should crash. If you scroll through the error message, you'll see the crash occurred because of a conflict in the unique identifier for the items.
335
+
1. This time, the program should crash. If you scroll through the error message, you see the crash occurred because of a conflict in the unique identifier for the items.
336
336
337
337
```output
338
338
Unhandled exception: Microsoft.Azure.Cosmos.CosmosException : Response status code does not indicate success: Conflict (409);Reason: (
@@ -415,7 +415,7 @@ Now that you've created your first item in the container, you can use the same S
1. The output of the command should indicate that the query required multiple RUs.
418
+
1. The output of the command should indicate that the query required multiple request units (RUs).
419
419
420
420
```output
421
421
[OK] mica-pereira 2.82 RUs
@@ -474,7 +474,7 @@ Now that you've created your first item in the container, you can use the same S
474
474
475
475
## Create a transaction using the SDK
476
476
477
-
Finally, you'll take the item you created, read that item, and create a different related item as part of a single transaction using the Azure SDK for .NET.
477
+
Finally, you take the item you created, read that item, and create a different related item as part of a single transaction using the Azure SDK for .NET.
478
478
479
479
1. Return to or open the **CosmosHandler.cs** file.
480
480
@@ -491,7 +491,7 @@ Finally, you'll take the item you created, read that item, and create a differen
491
491
492
492
1. For the next steps, add this new code within the `ManageCustomerAsync` method.
493
493
494
-
1. Create a new anonymous typed item using the `name`, `state`, and `country` method parameters and the `id` variable. Store the item as a variable named `customerCart`. This item will represent a real-time shopping cart for the customer that is currently empty.
494
+
1. Create a new anonymous typed item using the `name`, `state`, and `country` method parameters and the `id` variable. Store the item as a variable named `customerCart`. This item represents a real-time shopping cart for the customer that is currently empty.
495
495
496
496
```csharp
497
497
var customerCart = new {
@@ -505,7 +505,7 @@ Finally, you'll take the item you created, read that item, and create a differen
505
505
};
506
506
```
507
507
508
-
1. Create another new anonymous typed item using the `name`, `state`, and `country` method parameters and the `id` variable. Store the item as a variable named `customerCart`. This item will represent shipping and contact information for the customer.
508
+
1. Create another new anonymous typed item using the `name`, `state`, and `country` method parameters and the `id` variable. Store the item as a variable named `customerCart`. This item represents shipping and contact information for the customer.
509
509
510
510
```csharp
511
511
var customerContactInfo = new {
@@ -566,7 +566,7 @@ Finally, you'll take the item you created, read that item, and create a differen
566
566
567
567
## Validate the final data in the Data Explorer
568
568
569
-
To wrap up things, you'll use the Data Explorer in the Azure portal to view the data, and container you created in this tutorial.
569
+
To wrap up things, you use the Data Explorer in the Azure portal to view the data, and container you created in this tutorial.
570
570
571
571
1. Navigate to your existing API for NoSQL account in the [Azure portal](https://portal.azure.com/).
572
572
@@ -590,7 +590,7 @@ To wrap up things, you'll use the Data Explorer in the Azure portal to view the
590
590
591
591
1. Select **Execute Query** to run the query and observe the results.
592
592
593
-
:::image type="content" source="media/tutorial-dotnet-console-app/page-data-explorer-execute-query.png" alt-text="Screenshot of the Execute Query option in the Data Explorer command bar.":::
593
+
:::image type="content" source="media/tutorial-dotnet-console-app/page-data-explorer-execute-query.png" alt-text="Screenshot of the 'Execute Query' option in the Data Explorer command bar.":::
594
594
595
595
1. The results should include a JSON array with three items created in this tutorial. Observe that all of the items have the same hierarchical partition key value, but unique ID fields. The example output included is truncated for brevity.
0 commit comments