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 MongoDB 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
-
> [!NOTE]
30
-
> The [example code snippets](https://github.com/Azure-Samples/cosmos-db-mongodb-api-dotnet-samples) are available on GitHub as a .NET project.
20
+
Get started with MongoDB to create databases, collections, and docs within your Azure Cosmos DB resource. Follow these steps to deploy a minimal solution to your environment using the Azure Developer CLI.
31
21
32
22
[API for MongoDB reference documentation](https://www.mongodb.com/docs/drivers/csharp) | [MongoDB Package (NuGet)](https://www.nuget.org/packages/MongoDB.Driver)
-[Azure Command-Line Interface (CLI)](/cli/azure/install-azure-cli) or [Azure PowerShell](/powershell/azure/install-azure-powershell)
39
-
40
-
### Prerequisite check
41
-
42
-
- In a terminal or command window, run ``dotnet --list-sdks`` to check that .NET 6.x is one of the available 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.
This section walks you through creating an Azure Cosmos DB account and setting up a project that uses the MongoDB NuGet packages.
48
-
49
-
### Create an Azure Cosmos DB account
31
+
Deploy this project's development container to your environment. Then, use the Azure Developer CLI (`azd`) to create an Azure Cosmos DB for NoSQL account and deploy a containerized sample application. The sample application uses the client library to manage, create, read, and query sample data.
50
32
51
-
This quickstart will create a single Azure Cosmos DB account using the API for MongoDB.
33
+
::: zone pivot="devcontainer-codespace"
52
34
53
-
#### [Azure CLI](#tab/azure-cli)
35
+
[](https://github.com/alexwolfmsft/cosmos-db-mongo-dotnet-quickstart?template=false&quickstart=1&azure-portal=true)
[!INCLUDE [Powershell - create resource group and resources](./includes/powershell-create-resource-group-and-resource.md)]
41
+
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/alexwolfmsft/cosmos-db-mongo-dotnet-quickstart)
The client library is available through NuGet, as the `Microsoft.Azure.Cosmos` package.
70
52
71
-
[!INCLUDE [Azure CLI - get connection string](./includes/azure-cli-get-connection-string.md)]
53
+
1. Open a terminal and navigate to the `/src/web` folder.
72
54
73
-
#### [PowerShell](#tab/azure-powershell)
55
+
```bash
56
+
cd ./src/web
57
+
```
74
58
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
-
---
59
+
1. If not already installed, install the `MongoDb.Driver` package using `dotnet add package`.
82
60
83
-
### Create a new .NET app
84
-
85
-
Create a new .NET application in an empty folder using your preferred terminal. Use the [``dotnet new console``](/dotnet/core/tools/dotnet-new) to create a new console app.
86
-
87
-
```console
88
-
dotnet new console -o <app-name>
89
-
```
90
-
91
-
### Install the NuGet package
92
-
93
-
Add the [MongoDB.Driver](https://www.nuget.org/packages/MongoDB.Driver) NuGet package to the new .NET project. Use the [``dotnet add package``](/dotnet/core/tools/dotnet-add-package) command specifying the name of the NuGet package.
94
-
95
-
```console
96
-
dotnet add package MongoDb.Driver
97
-
```
61
+
```bash
62
+
dotnet add package MongoDb.Driver
63
+
```
98
64
99
-
### Configure environment variables
65
+
1. Also, install the `Azure.Identity` package if not already installed.
0 commit comments