Skip to content

Commit 142eb51

Browse files
authored
Merge pull request #272973 from alexwolfmsft/mongodb-quickstart-azd
Revamp quickstart for azd and codespaces
2 parents d300a01 + bbe89e8 commit 142eb51

File tree

5 files changed

+81
-53
lines changed

5 files changed

+81
-53
lines changed

articles/cosmos-db/mongodb/how-to-configure-capabilities.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Capabilities are features that can be added or removed to your API for MongoDB a
2020
## Prerequisites
2121

2222
- An Azure account with an active subscription. [Create an account for free](https://aka.ms/trycosmosdb).
23-
- An Azure Cosmos DB for MongoDB account. [Create an API for MongoDB account](quickstart-nodejs.md#create-an-azure-cosmos-db-account).
23+
- An Azure Cosmos DB for MongoDB account. [Create an API for MongoDB account](/azure/cosmos-db/how-to-manage-database-account).
2424
- [Azure CLI](/cli/azure/) or Azure portal access. Changing capabilities via Azure Resource Manager isn't supported.
2525

2626
## Available capabilities
@@ -32,13 +32,13 @@ Capabilities are features that can be added or removed to your API for MongoDB a
3232
| `EnableMongoRetryableWrites` | Enables support for retryable writes on the account. | Yes |
3333
| `EnableMongo16MBDocumentSupport` | Enables support for inserting documents up to 16 MB in size. | No |
3434
| `EnableUniqueCompoundNestedDocs` | Enables support for compound and unique indexes on nested fields if the nested field isn't an array. | No |
35-
| `EnableTtlOnCustomPath` | Provides the ability to set a custom Time to Live (TTL) on any one field in a collection. Setting TTL on partial unique index property is not supported. ¹ | No |
35+
| `EnableTtlOnCustomPath` | Provides the ability to set a custom Time to Live (TTL) on any one field in a collection. Setting TTL on partial unique index property is not supported. <sup>1</sup> | No |
3636
| `EnablePartialUniqueIndex` | Enables support for a unique partial index, so you have more flexibility to specify exactly which fields in documents you'd like to index. | No |
37-
| `EnableUniqueIndexReIndex` | Enables support for unique index re-indexing for Cosmos DB for MongoDB RU. ¹ | No |
37+
| `EnableUniqueIndexReIndex` | Enables support for unique index re-indexing for Cosmos DB for MongoDB RU. <sup>1</sup> | No |
3838

3939
> [!NOTE]
4040
>
41-
> ¹ This capability cannot be enabled on an Azure Cosmos DB for MongoDB accounts with continuous backup.
41+
> <sup>1</sup> This capability cannot be enabled on an Azure Cosmos DB for MongoDB accounts with continuous backup.
4242
>
4343
4444
## Enable a capability

articles/cosmos-db/mongodb/how-to-javascript-get-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This article shows you how to connect to Azure Cosmos DB for MongoDB using the n
2727
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free).
2828
- [Node.js LTS](https://nodejs.org/en/download/)
2929
- [Azure Command-Line Interface (CLI)](/cli/azure/) or [Azure PowerShell](/powershell/azure/)
30-
- [Azure Cosmos DB for MongoDB resource](quickstart-nodejs.md#create-an-azure-cosmos-db-account)
30+
- [Azure Cosmos DB for MongoDB resource](/azure/cosmos-db/how-to-manage-database-account)
3131

3232
## Create a new JavaScript app
3333

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
author: seesharprun
3+
ms.author: sidandrews
4+
ms.service: cosmos-db
5+
ms.subservice: nosql
6+
ms.topic: include
7+
ms.date: 01/08/2024
8+
ms.custom: include file
9+
zone_pivot_groups: azure-cosmos-db-quickstart-env
10+
---
11+
12+
::: zone pivot="devcontainer-codespace"
13+
14+
> [!IMPORTANT]
15+
> GitHub accounts include an entitlement of storage and core hours at no cost. For more information, see [included storage and core hours for GitHub accounts](https://docs.github.com/billing/managing-billing-for-github-codespaces/about-billing-for-github-codespaces#monthly-included-storage-and-core-hours-for-personal-accounts).
16+
17+
::: zone-end
18+
19+
::: zone pivot="devcontainer-vscode"
20+
21+
::: zone-end
22+
23+
1. Open a terminal in the root directory of the project.
24+
25+
1. Authenticate to the Azure Developer CLI using `azd auth login`. Follow the steps specified by the tool to authenticate to the CLI using your preferred Azure credentials.
26+
27+
```azurecli
28+
azd auth login
29+
```
30+
31+
1. Use `azd init` to initialize the project.
32+
33+
```azurecli
34+
azd init
35+
```
36+
37+
1. During initialization, configure a unique environment name.
38+
39+
> [!TIP]
40+
> The environment name will also be used as the target resource group name. For this quickstart, consider using `msdocs-cosmos-db-`.
41+
42+
1. Deploy the Azure Cosmos DB account using `azd up`. The Bicep templates also deploy a sample web application.
43+
44+
```azurecli
45+
azd up
46+
```
47+
48+
1. During the provisioning process, select your subscription and desired location. Wait for the provisioning process to complete. The process can take **approximately five minutes**.
49+
50+
1. Once the provisioning of your Azure resources is done, a URL to the running web application is included in the output.
51+
52+
```output
53+
Deploying services (azd deploy)
54+
55+
(✓) Done: Deploying service web
56+
- Endpoint: <https://[container-app-sub-domain].azurecontainerapps.io>
57+
58+
SUCCESS: Your application was provisioned and deployed to Azure in 5 minutes 0 seconds.
59+
```
60+
61+
1. Use the URL in the console to navigate to your web application in the browser. Observe the output of the running app.
62+
63+
:::image type="content" source="../media/quickstart-nodejs/dev-web-application-mongodb.png" alt-text="Screenshot of the running web application.":::
30.9 KB
Loading

articles/cosmos-db/mongodb/quickstart-nodejs.md

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ms.devlang: javascript
99
ms.topic: quickstart
1010
ms.date: 07/06/2022
1111
ms.custom: devx-track-js, devguide-js, cosmos-db-dev-journey, devx-track-azurecli
12+
zone_pivot_groups: azure-cosmos-db-quickstart-env
1213
---
1314

1415
# Quickstart: Azure Cosmos DB for MongoDB driver for Node.js
@@ -27,67 +28,35 @@ ms.custom: devx-track-js, devguide-js, cosmos-db-dev-journey, devx-track-azurecl
2728
Get started with the MongoDB npm package to create databases, collections, and docs within your Azure Cosmos DB resource. Follow these steps to install the package and try out example code for basic tasks.
2829

2930
> [!NOTE]
30-
> The [example code snippets](https://github.com/Azure-Samples/cosmos-db-mongodb-api-javascript-samples) are available on GitHub as a JavaScript project.
31+
> The [example code snippets](https://github.com/Azure-Samples/cosmos-db-mongodb-nodejs-quickstart) are available on GitHub as a JavaScript project.
3132
32-
[API for MongoDB reference documentation](https://docs.mongodb.com/drivers/node) | [MongoDB Package (NuGet)](https://www.npmjs.com/package/mongodb)
33+
[API for MongoDB reference documentation](https://www.mongodb.com/docs/drivers/csharp) | [MongoDB Package (NuGet)](https://www.nuget.org/packages/MongoDB.Driver)
34+
packages/Microsoft.Azure.Cosmos) | [Azure Developer CLI](/azure/developer/azure-developer-cli/overview)
3335

3436
## Prerequisites
3537

36-
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free).
37-
- [Node.js LTS](https://nodejs.org/en/download/)
38-
- [Azure Command-Line Interface (CLI)](/cli/azure/) or [Azure PowerShell](/powershell/azure/)
39-
40-
### Prerequisite check
41-
42-
- In a terminal or command window, run ``node --version`` to check that Node.js is one of the LTS versions.
43-
- Run ``az --version`` (Azure CLI) or ``Get-Module -ListAvailable AzureRM`` (Azure PowerShell) to check that you have the appropriate Azure command-line tools installed.
38+
[!INCLUDE [Developer Quickstart prerequisites](../nosql/includes/quickstart/dev-prereqs.md)]
4439

4540
## Setting up
4641

47-
This section walks you through creating an Azure Cosmos DB account and setting up a project that uses the MongoDB npm package.
48-
49-
### Create an Azure Cosmos DB account
42+
Deploy this project's development container to your environment. Then, use the Azure Developer CLI (`azd`) to create an Azure Cosmos DB for MongoDB account and deploy a containerized sample application. The sample application uses the client library to manage, create, read, and query sample data.
5043

51-
This quickstart will create a single Azure Cosmos DB account using the API for MongoDB.
44+
::: zone pivot="devcontainer-codespace"
5245

53-
#### [Azure CLI](#tab/azure-cli)
46+
[![Open in GitHub Codespaces](https://img.shields.io/static/v1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https://codespaces.new/Azure-Samples/cosmos-db-mongodb-nodejs-quickstart?template=false&quickstart=1&azure-portal=true)
5447

55-
[!INCLUDE [Azure CLI - create resources](./includes/azure-cli-create-resource-group-and-resource.md)]
48+
::: zone-end
5649

57-
#### [PowerShell](#tab/azure-powershell)
50+
::: zone pivot="devcontainer-vscode"
5851

59-
[!INCLUDE [Powershell - create resource group and resources](./includes/powershell-create-resource-group-and-resource.md)]
52+
[![Open in Dev Container](https://img.shields.io/static/v1?style=for-the-badge&label=Dev+Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/cosmos-db-mongodb-nodejs-quickstart)
6053

61-
#### [Portal](#tab/azure-portal)
54+
::: zone-end
6255

63-
[!INCLUDE [Portal - create resource](./includes/portal-create-resource.md)]
56+
[!INCLUDE [dev-setup](../nosql/includes/quickstart/dev-setup.md)]
6457

6558
---
6659

67-
### Get MongoDB connection string
68-
69-
#### [Azure CLI](#tab/azure-cli)
70-
71-
[!INCLUDE [Azure CLI - get connection string](./includes/azure-cli-get-connection-string.md)]
72-
73-
#### [PowerShell](#tab/azure-powershell)
74-
75-
[!INCLUDE [Powershell - get connection string](./includes/powershell-get-connection-string.md)]
76-
77-
#### [Portal](#tab/azure-portal)
78-
79-
[!INCLUDE [Portal - get connection string](./includes/portal-get-connection-string-from-resource.md)]
80-
81-
---
82-
83-
### Create a new JavaScript app
84-
85-
Create a new JavaScript application in an empty folder using your preferred terminal. Use the [``npm init``](https://docs.npmjs.com/cli/v8/commands/npm-init) command to begin the prompts to create the `package.json` file. Accept the defaults for the prompts.
86-
87-
```console
88-
npm init
89-
```
90-
9160
### Install the package
9261

9362
Add the [MongoDB](https://www.npmjs.com/package/mongodb) npm package to the JavaScript project. Use the [``npm install package``](https://docs.npmjs.com/cli/v8/commands/npm-install) command specifying the name of the npm package. The `dotenv` package is used to read the environment variables from a `.env` file during local development.
@@ -96,10 +65,6 @@ Add the [MongoDB](https://www.npmjs.com/package/mongodb) npm package to the Java
9665
npm install mongodb dotenv
9766
```
9867

99-
### Configure environment variables
100-
101-
[!INCLUDE [Multi-tab](./includes/environment-variables-connection-string.md)]
102-
10368
## Object model
10469

10570
Before you start building the application, let's look into the hierarchy of resources in Azure Cosmos DB. Azure Cosmos DB has a specific object model used to create and access resources. The Azure Cosmos DB creates resources in a hierarchy that consists of accounts, databases, collections, and docs.

0 commit comments

Comments
 (0)