Skip to content

Commit 2b30bb8

Browse files
authored
Merge pull request #199722 from GeekTrainer/master
Update Cosmos DB/Mongoose article for React template
2 parents ca44bf0 + b1120e6 commit 2b30bb8

File tree

1 file changed

+45
-41
lines changed

1 file changed

+45
-41
lines changed

articles/static-web-apps/add-mongoose.md

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.date: 01/25/2021
1010

1111
# Tutorial: Access data in Cosmos DB using Mongoose with Azure Static Web Apps
1212

13-
[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 Mongoose API. [Cosmos DB](../cosmos-db/mongodb-introduction.md) supports the necessary Mongoose APIs and is available as a back-end server option on Azure.
13+
[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. [Cosmos DB](../cosmos-db/mongodb-introduction.md) supports the necessary MongoDB APIs and is available as a back-end server option on Azure.
1414

1515
In this tutorial, you learn how to:
1616

@@ -35,21 +35,21 @@ Sign in to the [Azure portal](https://portal.azure.com).
3535
Begin by creating a [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.
3636

3737
1. Navigate to [https://portal.azure.com](https://portal.azure.com)
38-
2. Click **Create a resource**
38+
2. Select **Create a resource**
3939
3. Enter **Azure Cosmos DB** in the search box
40-
4. Click **Azure Cosmos DB**
41-
5. Click **Create**
40+
4. Select **Azure Cosmos DB**
41+
5. Select **Create**
4242
6. If prompted, under **Azure Cosmos DB API for MongoDB** select **Create**
4343
7. Configure your Azure Cosmos DB Account with the following information
4444
- Subscription: Choose the subscription you wish to use
45-
- Resource: Click **Create new**, and set the name to **aswa-mongoose**
45+
- Resource: Select **Create new**, and set the name to **aswa-mongoose**
4646
- Account name: A unique value is required
4747
- Location: **West US 2**
4848
- Capacity mode: **Serverless (preview)**
4949
- Version: **4.0**
5050
:::image type="content" source="media/add-mongoose/cosmos-db.png" alt-text="Create new Cosmos DB instance":::
51-
8. Click **Review + create**
52-
9. Click **Create**
51+
8. Select **Review + create**
52+
9. Select **Create**
5353

5454
The creation process will take a few minutes. Later steps will return to the database to gather the connection string.
5555

@@ -60,62 +60,66 @@ This tutorial uses a GitHub template repository to help you create your applicat
6060
1. Navigate to the [starter template](https://github.com/login?return_to=/staticwebdev/mongoose-starter/generate)
6161
2. Choose the **owner** (if using an organization other than your main account)
6262
3. Name your repository **aswa-mongoose-tutorial**
63-
4. Click **Create repository from template**
63+
4. Select **Create repository from template**
6464
5. Return to the [Azure portal](https://portal.azure.com)
65-
6. Click **Create a resource**
65+
6. Select **Create a resource**
6666
7. Type **static web app** in the search box
6767
8. Select **Static Web App**
68-
9. Click **Create**
68+
9. Select **Create**
6969
10. Configure your Azure Static Web App with the following information
7070
- Subscription: Choose the same subscription as before
7171
- Resource group: Select **aswa-mongoose**
7272
- Name: **aswa-mongoose-tutorial**
7373
- Region: **West US 2**
74-
- Click **Sign in with GitHub**
75-
- Click **Authorize** if prompted to allow Azure Static Web Apps to create the GitHub Action to enable deployment
74+
- Select **Sign in with GitHub**
75+
- Select **Authorize** if prompted to allow Azure Static Web Apps to create the GitHub Action to enable deployment
7676
- Organization: Your GitHub account name
7777
- Repository: **aswa-mongoose-tutorial**
7878
- Branch: **main**
79-
- Build presets: Choose **Custom**
80-
- App location: **/public**
79+
- Build presets: Choose **React**
80+
- App location: **/**
8181
- Api location: **api**
82-
- Output location: *leave blank*
82+
- Output location: **build**
8383
:::image type="content" source="media/add-mongoose/azure-static-web-apps.png" alt-text="Completed Azure Static Web Apps form":::
84-
11. Click **Review and create**
85-
12. Click **Create**
86-
13. The creation process takes a few moments; click on **Go to resource** once the static web app is provisioned
84+
11. Select **Review and create**
85+
12. Select **Create**
86+
13. The creation process takes a few moments; select **Go to resource** once the static web app is provisioned
8787

8888
## Configure database connection string
8989

9090
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.
9191

92-
1. Click **Home** in the upper left corner of the Azure portal (or navigate back to [https://portal.azure.com](https://portal.azure.com))
93-
2. Click **Resource groups**
94-
3. Click **aswa-mongoose**
95-
4. Click the name of your database account - it will have a type of **Azure Cosmos DB API for Mongo DB**
96-
5. Under **Settings** click **Connection String**
92+
1. Select **Home** in the upper left corner of the Azure portal (or navigate back to [https://portal.azure.com](https://portal.azure.com))
93+
2. Select **Resource groups**
94+
3. Select **aswa-mongoose**
95+
4. Select the name of your database account - it will have a type of **Azure Cosmos DB API for Mongo DB**
96+
5. Under **Settings** select **Connection String**
9797
6. Copy the connection string listed under **PRIMARY CONNECTION STRING**
98-
7. In the breadcrumbs, click **aswa-mongoose**
99-
8. Click **aswa-mongoose-tutorial** to return to the website instance
100-
9. Under **Settings** click **Configuration**
101-
10. Click **Add** and create a new Application Setting with the following values
102-
- Name: **CONNECTION_STRING**
103-
- Value: Paste the connection string you copied earlier
104-
11. Click **OK**
105-
12. Click **Save**
98+
7. In the breadcrumbs, select **aswa-mongoose**
99+
8. Select **aswa-mongoose-tutorial** to return to the website instance
100+
9. Under **Settings** select **Configuration**
101+
10. Select **Add** and create a new Application Setting with the following values
102+
- Name: **AZURE_COSMOS_CONNECTION_STRING**
103+
- Value: \<Paste the connection string you copied earlier\>
104+
11. Select **OK**
105+
12. Select **Add** and create a new Application Setting with the following values for name of the database
106+
- Name: **AZURE_COSMOS_DATABASE_NAME**
107+
- Value: **todo**
108+
13. Select **Save**
106109

107110
## Navigate to your site
108111

109112
You can now explore the static web app.
110113

111-
1. Click **Overview**
112-
1. Click the URL displayed in the upper right
114+
1. Select **Overview**
115+
1. Select the URL displayed in the upper right
113116
1. It will look similar to `https://calm-pond-05fcdb.azurestaticapps.net`
114-
1. Click **Please login to see your list of tasks**
115-
1. Click **Grant consent** to access the application
116-
1. Create a new task by typing in a title and clicking **Add task**
117+
1. Select **Please login to see your list of tasks**
118+
1. Select **Grant consent** to access the application
119+
1. Create a new lists by typing a name into the textbox labeled **create new list** and selecting **Save**
120+
1. Create a new task by typing in a title in the textbox labeled **create new item** and selecting **Save**
117121
1. Confirm the task is displayed (it may take a moment)
118-
1. Mark the task as complete by **clicking the checkbox**
122+
1. Mark the task as complete by **selecting the check**; the task will be moved to the **Done items** section of the page
119123
1. **Refresh the page** to confirm a database is being used
120124

121125
## Clean up resources
@@ -124,11 +128,11 @@ If you're not going to continue to use this application, delete
124128
the resource group with the following steps:
125129

126130
1. Return to the [Azure portal](https://portal.azure.com)
127-
2. Click **Resource groups**
128-
3. Click **aswa-mongoose**
129-
4. Click **Delete resource group**
131+
2. Select **Resource groups**
132+
3. Select **aswa-mongoose**
133+
4. Select **Delete resource group**
130134
5. Type **aswa-mongoose** into the textbox
131-
6. Click **Delete**
135+
6. Select **Delete**
132136

133137
## Next steps
134138

0 commit comments

Comments
 (0)