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
@@ -50,7 +50,7 @@ First, you'll create a database and container in the existing API for NoSQL acco
50
50
51
51
:::image type="content" source="media/tutorial-dotnet-web-app/resource-menu-keys.png" lightbox="media/tutorial-dotnet-web-app/resource-menu-keys.png" alt-text="Screenshot of an API for NoSQL account page. The Keys option is highlighted in the resource menu.":::
52
52
53
-
1. On the **Keys** page, observe and record the value of the **URI**, **PRIMARY KEY**, and **PRIMARY CONNECTION STRING***fields. These values will be used throughout the tutorial.
53
+
1. On the **Keys** page, observe and record the value of the **PRIMARY CONNECTION STRING***field. This value will be used throughout the tutorial.
54
54
55
55
:::image type="content" source="media/tutorial-dotnet-web-app/page-keys.png" alt-text="Screenshot of the Keys page with the URI, Primary Key, and Primary Connection String fields highlighted.":::
56
56
@@ -68,14 +68,14 @@ First, you'll create a database and container in the existing API for NoSQL acco
68
68
| --- | --- |
69
69
|**Database id**|`cosmicworks`|
70
70
|**Database throughput type**|**Manual**|
71
-
|**Database throughput amount**|`4000`|
71
+
|**Database throughput amount**|`1000`|
72
72
|**Container id**|`products`|
73
-
|**Partition key**|`/categoryId`|
73
+
|**Partition key**|`/category/name`|
74
74
75
75
:::image type="content" source="media/tutorial-dotnet-web-app/dialog-new-container.png" alt-text="Screenshot of the New Container dialog in the Data Explorer with various values in each field.":::
76
76
77
77
> [!IMPORTANT]
78
-
> In this tutorial, we will first scale the database up to 4,000 RU/s in shared throughput to maximize performance for the data migration. Once the data migration is complete, we will scale down to 400 RU/s of provisioned throughput.
78
+
> In this tutorial, we will first scale the database up to 1,000 RU/s in shared throughput to maximize performance for the data migration. Once the data migration is complete, we will scale down to 400 RU/s of provisioned throughput.
79
79
80
80
1. Select **OK** to create the database and container.
81
81
@@ -84,36 +84,41 @@ First, you'll create a database and container in the existing API for NoSQL acco
84
84
> [!TIP]
85
85
> You can optionally use the Azure Cloud Shell here.
86
86
87
-
1. Install a **pre-release**version of the `cosmicworks` dotnet tool from NuGet.
87
+
1. Install **v2** of the `cosmicworks` dotnet tool from NuGet.
1. Use the `cosmicworks` tool to populate your API forNoSQL account with sample product data using the **URI** and **PRIMARY KEY** values you recorded earlierin this lab. Those recorded values will be used for the `endpoint` and `key` parameters respectively.
94
94
95
95
```bash
96
96
cosmicworks \
97
-
--datasets product \
98
-
--endpoint <uri> \
99
-
--key <primary-key>
97
+
--number-of-products 1759 \
98
+
--number-of-employees 0 \
99
+
--disable-hierarchical-partition-keys \
100
+
--connection-string <nosql-connection-string>
100
101
```
101
102
102
-
1. Observe the output from the command line tool. It should add more than 200 items to the container. The example output included is truncated for brevity.
103
+
1. Observe the output from the command line tool. It should add 1759 items to the container. The example output included is truncated for brevity.
1. Return to the **Data Explorer** page for your account.
@@ -122,7 +127,7 @@ First, you'll create a database and container in the existing API for NoSQL acco
122
127
123
128
:::image type="content" source="media/tutorial-dotnet-web-app/section-data-database-scale.png" alt-text="Screenshot of the Scale option within the database node.":::
124
129
125
-
1. Reduce the throughput from **4,000** down to **400**.
130
+
1. Reduce the throughput from **1,000** down to **400**.
126
131
127
132
:::image type="content" source="media/tutorial-dotnet-web-app/section-scale-throughput.png" alt-text="Screenshot of the throughput settings for the database reduced down to 400 RU/s.":::
128
133
@@ -173,29 +178,33 @@ First, you'll create a database and container in the existing API for NoSQL acco
173
178
174
179
```sql
175
180
SELECT
176
-
p.name,
177
-
p.categoryName,
178
-
p.tags
181
+
p.name,
182
+
p.category.name AS category,
183
+
p.category.subCategory.name AS subcategory,
184
+
p.tags
179
185
FROM products p
180
-
JOIN t IN p.tags
181
-
WHERE t.name = "Tag-32"
186
+
JOIN tag IN p.tags
187
+
WHERE STRINGEQUALS(tag, "yellow", true)
182
188
```
183
189
184
190
1. The results should be a smaller array of items filtered to only contain items that include at least one tag with a **name** value of `Tag-32`. Again, a subset of the output is included here for brevity.
185
191
186
192
```output
187
-
...
188
-
{
189
-
"name": "ML Mountain Frame - Black, 44",
190
-
"categoryName": "Components, Mountain Frames",
191
-
"tags": [
192
-
{
193
-
"id": "18AC309F-F81C-4234-A752-5DDD2BEAEE83",
194
-
"name": "Tag-32"
195
-
}
193
+
[
194
+
...
195
+
{
196
+
"name": "HL Touring Frame - Yellow, 60",
197
+
"category": "Components",
198
+
"subcategory": "Touring Frames",
199
+
"tags": [
200
+
"Components",
201
+
"Touring Frames",
202
+
"Yellow",
203
+
"60"
204
+
]
205
+
},
206
+
...
196
207
]
197
-
},
198
-
...
199
208
```
200
209
201
210
## Create ASP.NET web application
@@ -263,9 +272,9 @@ Now, you'll create a new ASP.NET web application using a sample project template
new Product(id: "baaa4d2d-5ebe-45fb-9a5c-d06876f408e0", category: new Category(name: "Components, Road Frames"), sku: "FR-R72R-60", name: """ML Road Frame - Red, 60""", description: """The product called "ML Road Frame - Red, 60".""", price: 594.83000000000004m),
276
+
new Product(id: "bd43543e-024c-4cda-a852-e29202310214", category: new Category(name: "Components, Forks"), sku: "FK-5136", name: """ML Fork""", description: """The product called "ML Fork".""", price: 175.49000000000001m),
277
+
...
269
278
};
270
279
}
271
280
```
@@ -277,20 +286,25 @@ Now, you'll create a new ASP.NET web application using a sample project template
277
286
{ }
278
287
```
279
288
280
-
1. Finally, navigate to and open the **Models/Product.cs** file. Observe the record type defined in this file. This type will be used in queries throughout this tutorial.
289
+
1. Finally, navigate to and open the **Models/Product.cs**and **Models/Category.cs** files. Observe the record types defined ineach file. These types will be used in queries throughout this tutorial.
281
290
282
291
```csharp
283
292
public record Product(
284
293
string id,
285
-
string categoryId,
286
-
string categoryName,
294
+
Category category,
287
295
string sku,
288
296
string name,
289
297
string description,
290
298
decimal price
291
299
);
292
300
```
293
301
302
+
```csharp
303
+
public record Category(
304
+
string name
305
+
);
306
+
```
307
+
294
308
## Query data using the .NET SDK
295
309
296
310
Next, you'll add the Azure SDK for .NET to this sample project and use the library to query data from the API for NoSQL container.
@@ -429,26 +443,24 @@ Next, you'll add the Azure SDK for .NET to this sample project and use the libra
429
443
string sql = """
430
444
SELECT
431
445
p.id,
432
-
p.categoryId,
433
-
p.categoryName,
434
-
p.sku,
435
446
p.name,
447
+
p.category,
448
+
p.sku,
436
449
p.description,
437
-
p.price,
438
-
p.tags
450
+
p.price
439
451
FROM products p
440
-
JOIN t IN p.tags
441
-
WHERE t.name = @tagFilter
452
+
JOIN tag IN p.tags
453
+
WHERE STRINGEQUALS(tag, @tagFilter, true)
442
454
""";
443
455
```
444
456
445
-
1. Create a new `QueryDefinition` variable named `query` passing in the `sql` string as the only query parameter. Also, use the `WithParameter` fluid method to apply the value `Tag-75` to the `@tagFilter` parameter.
457
+
1. Create a new `QueryDefinition` variable named `query` passing in the `sql` string as the only query parameter. Also, use the `WithParameter` fluid method to apply the value `red` to the `@tagFilter` parameter.
446
458
447
459
```csharp
448
460
var query = new QueryDefinition(
449
461
query: sql
450
462
)
451
-
.WithParameter("@tagFilter", "Tag-75");
463
+
.WithParameter("@tagFilter", "red");
452
464
```
453
465
454
466
1. Use the `GetItemQueryIterator<>` generic method and the `query` variable to create an iterator that gets data from Azure Cosmos DB. Store the iterator in a variable named `feed`. Wrap this entire expression in a using statement to dispose the iterator later.
0 commit comments