Skip to content

Commit 844115e

Browse files
authored
Merge pull request #214125 from chcomley/users/chcomley/swa-blazor-1995786
Refresh deploy-blazor.md
2 parents dc4eeea + 92928bf commit 844115e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+514
-460
lines changed
Lines changed: 72 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,59 @@
11
---
2-
title: "Tutorial: Access data in Azure Cosmos DB using Mongoose with Azure Static Web Apps"
2+
title: "Access data in Azure Cosmos DB using Mongoose with Azure Static Web Apps"
33
description: Learn to access data in Azure Cosmos DB using Mongoose from an Azure Static Web Apps API function.
44
author: GeekTrainer
55
ms.author: chrhar
66
ms.service: static-web-apps
77
ms.custom: ignite-2022
88
ms.topic: tutorial
9-
ms.date: 01/25/2021
9+
ms.date: 10/10/2022
1010
---
1111

12-
# Tutorial: Access data in Azure Cosmos DB using Mongoose with Azure Static Web Apps
13-
14-
[Mongoose](https://mongoosejs.com/) is the most popular ODM (Object Document Mapping) client for Node.js. Allowing you to design a data structure and enforce validation, Mongoose provides all the tooling necessary to interact with databases that support the MongoDB API. [Azure Cosmos DB for MongoDB](../cosmos-db/mongodb-introduction.md) supports the necessary MongoDB APIs and is available as a back-end server option on Azure.
15-
16-
In this tutorial, you learn how to:
17-
18-
> [!div class="checklist"]
19-
> - Create an Azure Cosmos DB serverless account
20-
> - Create Azure Static Web Apps
21-
> - Update application settings to store the connection string
22-
23-
If you don’t have an Azure subscription, create a [free trial account](https://azure.microsoft.com/free/).
12+
# Access data in Azure Cosmos DB using Mongoose with Azure Static Web Apps
2413

14+
[Mongoose](https://mongoosejs.com/) is the most popular ODM (Object Document Mapping) client for Node.js. Mongoose allows you to design a data structure and enforce validation, and provides all the tooling necessary to interact with databases that support the MongoDB API. [Cosmos DB](../cosmos-db/mongodb-introduction.md) supports the necessary MongoDB APIs and is available as a back-end server option on Azure.
2515
## Prerequisites
2616

27-
- An [Azure account](https://azure.microsoft.com/free/)
28-
- A [GitHub account](https://github.com/join)
29-
30-
## Sign in to Azure
31-
32-
Sign in to the [Azure portal](https://portal.azure.com).
17+
- An [Azure account](https://azure.microsoft.com/free/). If you don’t have an Azure subscription, create a [free trial account](https://azure.microsoft.com/free/).
18+
- A [GitHub account](https://github.com/join).
19+
- A [Cosmos DB serverless](../cosmos-db/serverless.md) account. With a serverless account, you only pay for the resources as they're used and avoid needing to create a full infrastructure.
20+
## 1. Create a Cosmos DB serverless database
3321

34-
## Create an Azure Cosmos DB serverless database
22+
Complete the following steps to create a Cosmos serverless DB.
3523

36-
Begin by creating an [Azure Cosmos DB serverless](../cosmos-db/serverless.md) account. By using a serverless account, you only pay for the resources as they are used and avoid needing to create a full infrastructure.
37-
38-
1. Navigate to the [Azure portal](https://portal.azure.com)
39-
2. Select **Create a resource**
40-
3. Enter **Azure Cosmos DB** in the search box
41-
4. Select **Azure Cosmos DB**
42-
5. Select **Create**
43-
6. If prompted, under **Azure Cosmos DB for MongoDB** select **Create**
44-
7. Configure your Azure Cosmos DB Account with the following information
24+
1. Sign in to the [Azure portal](https://portal.azure.com).
25+
2. Select **Create a resource**.
26+
3. Enter *Azure Cosmos DB* in the search box.
27+
4. Select **Azure Cosmos DB**.
28+
5. Select **Create**.
29+
6. If prompted, under **Azure Cosmos DB API for MongoDB** select **Create**.
30+
7. Configure your Azure Cosmos DB Account with the following information:
4531
- Subscription: Choose the subscription you wish to use
4632
- Resource: Select **Create new**, and set the name to **aswa-mongoose**
4733
- Account name: A unique value is required
4834
- Location: **West US 2**
4935
- Capacity mode: **Serverless (preview)**
5036
- Version: **4.0**
51-
:::image type="content" source="media/add-mongoose/cosmos-db.png" alt-text="Create new Azure Cosmos DB instance":::
52-
8. Select **Review + create**
53-
9. Select **Create**
37+
:::image type="content" source="media/add-mongoose/cosmos-db.png" alt-text="Screenshot showing form for creating new Cosmos DB instance.":::
38+
8. Select **Review + create**.
39+
9. Select **Create**.
5440

55-
The creation process will take a few minutes. Later steps will return to the database to gather the connection string.
41+
The creation process takes a few minutes. We'll come back to the database to gather the connection string after we [create a static web app](#2-create-a-static-web-app).
5642

57-
## Create a static web app
43+
## 2. Create a static web app
5844

5945
This tutorial uses a GitHub template repository to help you create your application.
6046

61-
1. Navigate to the [starter template](https://github.com/login?return_to=/staticwebdev/mongoose-starter/generate)
62-
2. Choose the **owner** (if using an organization other than your main account)
63-
3. Name your repository **aswa-mongoose-tutorial**
64-
4. Select **Create repository from template**
65-
5. Return to the [Azure portal](https://portal.azure.com)
66-
6. Select **Create a resource**
67-
7. Type **static web app** in the search box
68-
8. Select **Static Web App**
69-
9. Select **Create**
70-
10. Configure your Azure Static Web App with the following information
47+
1. Go to the [starter template](https://github.com/login?return_to=/staticwebdev/mongoose-starter/generate).
48+
2. Choose the **owner** (if using an organization other than your main account).
49+
3. Name your repository **aswa-mongoose-tutorial**.
50+
4. Select **Create repository from template**.
51+
5. Return to the [Azure portal](https://portal.azure.com).
52+
6. Select **Create a resource**.
53+
7. Enter **static web app** in the search box.
54+
8. Select **Static Web App**.
55+
9. Select **Create**.
56+
10. Configure your Azure Static Web App with the following information:
7157
- Subscription: Choose the same subscription as before
7258
- Resource group: Select **aswa-mongoose**
7359
- Name: **aswa-mongoose-tutorial**
@@ -82,61 +68,63 @@ This tutorial uses a GitHub template repository to help you create your applicat
8268
- Api location: **api**
8369
- Output location: **build**
8470
:::image type="content" source="media/add-mongoose/azure-static-web-apps.png" alt-text="Completed Azure Static Web Apps form":::
85-
11. Select **Review and create**
86-
12. Select **Create**
87-
13. The creation process takes a few moments; select **Go to resource** once the static web app is provisioned
88-
89-
## Configure database connection string
90-
91-
In order to allow the web app to communicate with the database, the database connection string is stored as an [Application Setting](application-settings.md). Setting values are accessible in Node.js using the `process.env` object.
92-
93-
1. Select **Home** in the upper left corner of the Azure portal (or navigate back to [https://portal.azure.com](https://portal.azure.com))
94-
2. Select **Resource groups**
95-
3. Select **aswa-mongoose**
96-
4. Select the name of your database account - it will have a type of **Azure Cosmos DB for Mongo DB**
97-
5. Under **Settings** select **Connection String**
98-
6. Copy the connection string listed under **PRIMARY CONNECTION STRING**
99-
7. In the breadcrumbs, select **aswa-mongoose**
100-
8. Select **aswa-mongoose-tutorial** to return to the website instance
101-
9. Under **Settings** select **Configuration**
102-
10. Select **Add** and create a new Application Setting with the following values
71+
72+
11. Select **Review and create**.
73+
12. Select **Create**.
74+
13. The creation process takes a few moments; select **Go to resource** once the static web app is provisioned.
75+
76+
## 3. Configure database connection string
77+
78+
To allow the web app to communicate with the database, the database connection string is stored as an [application setting](application-settings.md). Setting values are accessible in Node.js using the `process.env` object.
79+
80+
1. Select **Home** in the upper left corner of the Azure portal (or go back to [https://portal.azure.com](https://portal.azure.com)).
81+
2. Select **Resource groups**.
82+
3. Select **aswa-mongoose**.
83+
4. Select the name of your database account - it has a type of **Azure Cosmos DB API for Mongo DB**.
84+
5. Under **Settings** select **Connection String**.
85+
6. Copy the connection string listed under **PRIMARY CONNECTION STRING**.
86+
7. In the breadcrumbs, select **aswa-mongoose**.
87+
8. Select **aswa-mongoose-tutorial** to return to the website instance.
88+
9. Under **Settings** select **Configuration**.
89+
10. Select **Add** and create a new Application Setting with the following values:
10390
- Name: **AZURE_COSMOS_CONNECTION_STRING**
10491
- Value: \<Paste the connection string you copied earlier\>
105-
11. Select **OK**
106-
12. Select **Add** and create a new Application Setting with the following values for name of the database
92+
11. Select **OK**.
93+
12. Select **Add** and create a new Application Setting with the following values for name of the database:
10794
- Name: **AZURE_COSMOS_DATABASE_NAME**
10895
- Value: **todo**
109-
13. Select **Save**
96+
13. Select **OK**.
97+
14. Select **Save**.
11098

111-
## Navigate to your site
99+
## 4. Go to your site
112100

113101
You can now explore the static web app.
114102

115-
1. Select **Overview**
116-
1. Select the URL displayed in the upper right
117-
1. It will look similar to `https://calm-pond-05fcdb.azurestaticapps.net`
118-
1. Select **Please login to see your list of tasks**
119-
1. Select **Grant consent** to access the application
120-
1. Create a new lists by typing a name into the textbox labeled **create new list** and selecting **Save**
121-
1. Create a new task by typing in a title in the textbox labeled **create new item** and selecting **Save**
122-
1. Confirm the task is displayed (it may take a moment)
123-
1. Mark the task as complete by **selecting the check**; the task will be moved to the **Done items** section of the page
124-
1. **Refresh the page** to confirm a database is being used
103+
1. In the Azure portal, select **Overview**.
104+
2. Select the URL displayed in the upper right.
105+
1. It looks similar to `https://calm-pond-05fcdb.azurestaticapps.net`.
106+
3. Select **Please login to see your list of tasks**.
107+
4. Select **Grant consent** to access the application.
108+
5. Create a new list by entering a name into the textbox labeled **create new list** and selecting **Save**.
109+
6. Create a new task by typing in a title in the textbox labeled **create new item** and selecting **Save**.
110+
7. Confirm the task is displayed (it may take a moment).
111+
8. Mark the task as complete by **selecting the check**; the task moves to the **Done items** section of the page.
112+
9. **Refresh the page** to confirm a database is being used.
125113

126114
## Clean up resources
127115

128116
If you're not going to continue to use this application, delete
129117
the resource group with the following steps:
130118

131-
1. Return to the [Azure portal](https://portal.azure.com)
132-
2. Select **Resource groups**
133-
3. Select **aswa-mongoose**
134-
4. Select **Delete resource group**
135-
5. Type **aswa-mongoose** into the textbox
136-
6. Select **Delete**
119+
1. Return to the [Azure portal](https://portal.azure.com).
120+
2. Select **Resource groups**.
121+
3. Select **aswa-mongoose**.
122+
4. Select **Delete resource group**.
123+
5. Enter **aswa-mongoose** into the textbox.
124+
6. Select **Delete**.
137125

138126
## Next steps
139127

140128
Advance to the next article to learn how to configure local development...
141129
> [!div class="nextstepaction"]
142-
> [Setup local development](./local-development.md)
130+
> [Set up local development](./local-development.md)

articles/static-web-apps/apex-domain-azure-dns.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ The following procedure requires you to copy settings from an Azure DNS zone you
2121

2222
1. Open the [Azure portal](https://portal.azure.com).
2323

24-
1. Navigate to your static web app.
24+
1. Go to your static web app.
2525

2626
1. Under *Settings*, select **Custom domains**.
2727

28-
1. Select the **+ Add** button, and select **Custom Domain on Azure DNS** from the drop down.
28+
1. Select **+ Add**, and then select **Custom Domain on Azure DNS** from the drop down menu.
2929

3030
1. In the *Enter domain* tab, enter your apex domain name.
3131

3232
For instance, if your domain name is `example.com`, enter `example.com` into this box (without any subdomains).
3333

34-
1. Select the **Next** button.
34+
1. Select **Next**.
3535

3636
1. In the *Validate + Configure* tab, enter the following values.
3737

@@ -40,17 +40,17 @@ The following procedure requires you to copy settings from an Azure DNS zone you
4040
| Domain name | This value should match the domain name you entered in the previous step. |
4141
| Hostname record type | Select **TXT**. |
4242

43-
1. Select the **Generate code** button.
43+
1. Select **Generate code**.
4444

4545
Wait as the code is generated. It make take a minute or so to complete.
4646

47-
1. Once the `TXT` record value is generated, select the **copy button** (next to the generated value) to copy the code to the clipboard.
47+
1. Once the `TXT` record value is generated, **copy** (next to the generated value) the code to the clipboard.
4848

49-
1. Select the **Close** button.
49+
1. Select **Close**.
5050

51-
1. Navigate to your Azure DNS zone instance.
51+
1. Go to your Azure DNS zone instance.
5252

53-
1. Select the **+ Record set** button.
53+
1. Select **+ Record set**.
5454

5555
1. Enter the following values in the *Add record set* window.
5656

@@ -62,23 +62,23 @@ The following procedure requires you to copy settings from an Azure DNS zone you
6262
| TTL unit | Keep default value. |
6363
| Value | Paste in the `TXT` record value in your clipboard from your static web app. |
6464

65-
1. Select the **OK** button.
65+
1. Select **OK**.
6666

6767
1. Return to your static web app in the Azure portal.
6868

6969
1. Under *Settings*, select **Custom domains**.
7070

71-
Observe the *Status* for the row of your apex domain. Once the validation is complete, then your apex domain will be publicly available.
71+
Observe the *Status* for the row of your apex domain. Once the validation is complete, then your apex domain is publicly available.
7272

7373
While this validation is running, create an ALIAS record to finalize the configuration.
7474

7575
## Set up ALIAS record
7676

7777
1. Return to the Azure DNS zone in the Azure portal.
7878

79-
1. Select the **+ Record set button** button.
79+
2. Select **+ Record set**.
8080

81-
1. Enter the following values in the *Add record set* window.
81+
3. Enter the following values in the *Add record set* window.
8282

8383
| Setting | Property |
8484
|---|---|
@@ -91,9 +91,9 @@ While this validation is running, create an ALIAS record to finalize the configu
9191
| TTL | Keep default value. |
9292
| TTL unit | Keep default value. |
9393

94-
1. Select the **OK** button.
94+
4. Select **OK**.
9595

96-
1. Open a new browser tab and navigate to your apex domain.
96+
5. Open a new browser tab and go to your apex domain.
9797

9898
After the DNS records are updated, you should see your static web app in the browser. Also, inspect the location to verify that your site is served securely using `https`.
9999

articles/static-web-apps/apex-domain-external.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,40 @@ Before you create the `ALIAS` record, you first need to validate that you own th
3636

3737
1. Open the [Azure portal](https://portal.azure.com).
3838

39-
1. Navigate to your static web app.
39+
1. Go to your static web app.
4040

4141
1. From the *Overview* window, copy the generated **URL** of your site and set it aside in a text editor for future use.
4242

4343
1. Under *Settings*, select **Custom domains**.
4444

45-
1. Select the **+ Add** button.
45+
2. Select **+ Add**.
4646

47-
1. In the *Enter domain* tab, enter your apex domain name.
47+
3. In the *Enter domain* tab, enter your apex domain name.
4848

4949
For instance, if your domain name is `example.com`, enter `example.com` into this box (without any subdomains).
5050

51-
1. Select the **Next** button.
51+
4. Select **Next**.
5252

53-
1. In the *Validate + Configure* tab, enter the following values.
53+
5. In the *Validate + Configure* tab, enter the following values.
5454

5555
| Setting | Value |
5656
|---|---|
5757
| Domain name | This value should match the domain name you entered in the previous step. |
5858
| Hostname record type | Select **TXT**. |
5959

60-
1. Select the **Generate code** button.
60+
6. Select **Generate code**.
6161

6262
Wait as the code is generated. It make take a minute or so to complete.
6363

64-
1. Once the `TXT` record value is generated, select the **copy button** (next to the generated value) to copy the code to the clipboard.
64+
7. Once the `TXT` record value is generated, **copy** (next to the generated value) the code to the clipboard.
6565

66-
1. Select the **Close** button.
66+
8. Select **Close**.
6767

68-
1. Open a new browser tab and sign in to your domain registrar account.
68+
9. Open a new browser tab and sign in to your domain registrar account.
6969

70-
1. Navigate to your domain name's DNS configuration settings.
70+
10. Go to your domain name's DNS configuration settings.
7171

72-
1. Add a new `TXT` record with the following values.
72+
11. Add a new `TXT` record with the following values.
7373

7474
| Setting | Value |
7575
|--|--|
@@ -78,7 +78,7 @@ Before you create the `ALIAS` record, you first need to validate that you own th
7878
| Value | Paste the generated code value you copied from the Azure portal. |
7979
| TTL (if applicable) | Leave as default value. |
8080

81-
1. Save changes to your DNS record.
81+
12. Save changes to your DNS record.
8282

8383
### Set up an ALIAS record
8484

@@ -97,7 +97,7 @@ Before you create the `ALIAS` record, you first need to validate that you own th
9797

9898
Since DNS settings need to propagate, this process can take some time to complete.
9999

100-
1. Open a new browser tab and navigate to your apex domain.
100+
1. Open a new browser tab and go to your apex domain.
101101

102102
After the DNS records are updated, you should see your static web app in the browser. Also, inspect the location to verify that your site is served securely using `https`.
103103

articles/static-web-apps/apis-api-management.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ All Azure API Management pricing tiers are available for use with Azure Static W
3030

3131
To link an Azure API Management service as the API backend for a static web app, follow these steps:
3232

33-
1. In the Azure portal, navigate to the static web app.
33+
1. In the Azure portal, go to the static web app.
3434

3535
1. Select **APIs** from the navigation menu.
3636

@@ -69,13 +69,13 @@ The linking process also automatically applies the following configuration to yo
6969
* The linked static web app is configured to include the subscription's primary key and a valid access token when proxying requests to the API Management service.
7070

7171
> [!IMPORTANT]
72-
> Changing the *validate-jwt* policy or regenerating the subscription's primary key will prevent your static web app from proxying requests to the API Management service. Do not modify or delete the subscription or product associated with your static web app while they are linked.
72+
> Changing the *validate-jwt* policy or regenerating the subscription's primary key prevents your static web app from proxying requests to the API Management service. Do not modify or delete the subscription or product associated with your static web app while they are linked.
7373
7474
## Unlink an Azure API Management service
7575

7676
To unlink an Azure API Management service from a static web app, follow these steps:
7777

78-
1. In the Azure portal, navigate to the static web app.
78+
1. In the Azure portal, go to the static web app.
7979

8080
1. Locate the environment that you want to unlink and select the API Management service name.
8181

0 commit comments

Comments
 (0)