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
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.
28
29
29
-
> [!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
-
32
-
[API for MongoDB reference documentation](https://docs.mongodb.com/drivers/node) | [MongoDB Package (NuGet)](https://www.npmjs.com/package/mongodb)
30
+
[API for MongoDB reference documentation](https://www.mongodb.com/docs/drivers/csharp) | [MongoDB Package (NuGet)](https://www.nuget.org/packages/MongoDB.Driver)
- 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.
[!INCLUDE [Powershell - create resource group and resources](./includes/powershell-create-resource-group-and-resource.md)]
39
+
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.
[](https://codespaces.new/alexwolfmsft/cosmos-db-mongodb-nodejs-quickstart?template=false&quickstart=1&azure-portal=true)
64
44
65
-
---
66
-
67
-
### Get MongoDB connection string
68
-
69
-
#### [Azure CLI](#tab/azure-cli)
45
+
::: zone-end
70
46
71
-
[!INCLUDE [Azure CLI - get connection string](./includes/azure-cli-get-connection-string.md)]
47
+
::: zone pivot="devcontainer-vscode"
72
48
73
-
#### [PowerShell](#tab/azure-powershell)
49
+
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/alexwolfmsft/cosmos-db-mongodb-nodejs-quickstart)
74
50
75
-
[!INCLUDE [Powershell - get connection string](./includes/powershell-get-connection-string.md)]
51
+
::: zone-end
76
52
77
-
#### [Portal](#tab/azure-portal)
78
-
79
-
[!INCLUDE [Portal - get connection string](./includes/portal-get-connection-string-from-resource.md)]
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
-
91
57
### Install the package
92
58
93
59
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.
0 commit comments