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.
19
+
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
20
32
21
[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.
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.
56
31
57
-
#### [PowerShell](#tab/azure-powershell)
32
+
::: zone pivot="devcontainer-codespace"
58
33
59
-
[!INCLUDE [Powershell - create resource group and resources](./includes/powershell-create-resource-group-and-resource.md)]
34
+
[](https://codespaces.new/azure-samples/cosmos-db-mongodb-dotnet-quickstart?template=false&quickstart=1&azure-portal=true)
[!INCLUDE [Azure CLI - get connection string](./includes/azure-cli-get-connection-string.md)]
40
+
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/azure-samples/cosmos-db-mongodb-dotnet-quickstart)
72
41
73
-
#### [PowerShell](#tab/azure-powershell)
42
+
::: zone-end
74
43
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)]
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.
50
+
The client library is available through NuGet, as the `Microsoft.Azure.Cosmos` package.
86
51
87
-
```console
88
-
dotnet new console -o <app-name>
89
-
```
52
+
1. Open a terminal and navigate to the `/src/web` folder.
90
53
91
-
### Install the NuGet package
54
+
```bash
55
+
cd ./src/web
56
+
```
92
57
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.
58
+
1. If not already installed, install the `MongoDb.Driver` package using `dotnet add package`.
94
59
95
-
```console
96
-
dotnet add package MongoDb.Driver
97
-
```
60
+
```bash
61
+
dotnet add package MongoDb.Driver
62
+
```
98
63
99
-
### Configure environment variables
64
+
1. Also, install the `Azure.Identity` package if not already installed.
0 commit comments