Skip to content

Commit e266e7f

Browse files
authored
Merge pull request #269202 from alexwolfmsft/azd-mongodb-quickstart
Update mongodb quickstart to use azd
2 parents e2cd8a5 + 2c7d73f commit e266e7f

File tree

3 files changed

+30
-63
lines changed

3 files changed

+30
-63
lines changed

articles/cosmos-db/mongodb/how-to-dotnet-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 .NET
2727
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free).
2828
- [.NET 6.0](https://dotnet.microsoft.com/download)
2929
- [Azure Command-Line Interface (CLI)](/cli/azure/) or [Azure PowerShell](/powershell/azure/)
30-
- [Azure Cosmos DB for MongoDB resource](quickstart-dotnet.md#create-an-azure-cosmos-db-account)
30+
- [Azure Cosmos DB for MongoDB resource](../nosql/how-to-dotnet-create-database.md)
3131

3232
## Create a new .NET Core app
3333

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

Lines changed: 27 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,96 +9,63 @@ ms.devlang: csharp
99
ms.topic: quickstart
1010
ms.date: 07/06/2022
1111
ms.custom: devx-track-csharp, mode-api, devguide-csharp, cosmos-db-dev-journey, devx-track-azurecli, devx-track-dotnet
12+
zone_pivot_groups: azure-cosmos-db-quickstart-env
1213
---
1314

1415
# Quickstart: Azure Cosmos DB for MongoDB for .NET with the MongoDB driver
1516

1617
[!INCLUDE[MongoDB](../includes/appliesto-mongodb.md)]
1718

18-
> [!div class="op_single_selector"]
19-
>
20-
> * [.NET](quickstart-dotnet.md)
21-
> * [Python](quickstart-python.md)
22-
> * [Java](quickstart-java.md)
23-
> * [Node.js](quickstart-nodejs.md)
24-
> * [Go](quickstart-go.md)
25-
>
26-
27-
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.
3120

3221
[API for MongoDB reference documentation](https://www.mongodb.com/docs/drivers/csharp) | [MongoDB Package (NuGet)](https://www.nuget.org/packages/MongoDB.Driver)
22+
packages/Microsoft.Azure.Cosmos) | [Azure Developer CLI](/azure/developer/azure-developer-cli/overview)
3323

3424
## Prerequisites
3525

36-
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free).
37-
- [.NET 6.0](https://dotnet.microsoft.com/download)
38-
- [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.
26+
[!INCLUDE [Developer Quickstart prerequisites](../nosql/includes/quickstart/dev-prereqs.md)]
4427

4528
## Setting up
4629

47-
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
50-
51-
This quickstart will create a single Azure Cosmos DB account using the API for MongoDB.
52-
53-
#### [Azure CLI](#tab/azure-cli)
54-
55-
[!INCLUDE [Azure CLI - create resources](./includes/azure-cli-create-resource-group-and-resource.md)]
30+
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.
5631

57-
#### [PowerShell](#tab/azure-powershell)
32+
::: zone pivot="devcontainer-codespace"
5833

59-
[!INCLUDE [Powershell - create resource group and resources](./includes/powershell-create-resource-group-and-resource.md)]
34+
[![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-dotnet-quickstart?template=false&quickstart=1&azure-portal=true)
6035

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

63-
[!INCLUDE [Portal - create resource](./includes/portal-create-resource.md)]
38+
::: zone pivot="devcontainer-vscode"
6439

65-
---
66-
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)]
40+
[![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-dotnet-quickstart)
7241

73-
#### [PowerShell](#tab/azure-powershell)
42+
::: zone-end
7443

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)]
44+
[!INCLUDE [dev-setup](../nosql/includes/quickstart/dev-setup.md)]
8045

8146
---
8247

83-
### Create a new .NET app
48+
### Install the client library
8449

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.
50+
The client library is available through NuGet, as the `Microsoft.Azure.Cosmos` package.
8651

87-
```console
88-
dotnet new console -o <app-name>
89-
```
52+
1. Open a terminal and navigate to the `/src/web` folder.
9053

91-
### Install the NuGet package
54+
```bash
55+
cd ./src/web
56+
```
9257

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`.
9459

95-
```console
96-
dotnet add package MongoDb.Driver
97-
```
60+
```bash
61+
dotnet add package MongoDb.Driver
62+
```
9863

99-
### Configure environment variables
64+
1. Also, install the `Azure.Identity` package if not already installed.
10065

101-
[!INCLUDE [Multi-tab](./includes/environment-variables-connection-string.md)]
66+
```bash
67+
dotnet add package Azure.Identity
68+
```
10269

10370
## Object model
10471

@@ -199,7 +166,7 @@ Sand Surfboard
199166

200167
## Clean up resources
201168

202-
When you no longer need the Azure Cosmos DB for NoSQL account, you can delete the corresponding resource group.
169+
When you no longer need the Azure Cosmos DB for MongoDB account, you can delete the corresponding resource group.
203170

204171
### [Azure CLI / Resource Manager template](#tab/azure-cli)
205172

articles/cosmos-db/nosql/includes/quickstart/dev-setup.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ zone_pivot_groups: azure-cosmos-db-quickstart-env
3737
1. During initialization, configure a unique environment name.
3838
3939
> [!TIP]
40-
> The environment name will also be used as the target resource group name. For this quickstart, consider using `msdocs-cosmos-db-nosql`.
40+
> The environment name will also be used as the target resource group name. For this quickstart, consider using `msdocs-cosmos-db-`.
4141
42-
1. Deploy the Azure Cosmos DB for NoSQL account using `azd up`. The Bicep templates also deploy a sample web application.
42+
1. Deploy the Azure Cosmos DB account using `azd up`. The Bicep templates also deploy a sample web application.
4343
4444
```azurecli
4545
azd up

0 commit comments

Comments
 (0)