Skip to content

Commit 7ea8dc5

Browse files
committed
initial commit
1 parent 98b5265 commit 7ea8dc5

File tree

1 file changed

+26
-58
lines changed

1 file changed

+26
-58
lines changed

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

Lines changed: 26 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,90 +15,58 @@ ms.custom: devx-track-csharp, mode-api, devguide-csharp, cosmos-db-dev-journey,
1515

1616
[!INCLUDE[MongoDB](../includes/appliesto-mongodb.md)]
1717

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-
>
18+
[!INCLUDE[Developer Quickstart selector](includes/quickstart/dev-selector.md)]
2619

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.
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.
3121

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

3425
## Prerequisites
3526

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.
27+
[!INCLUDE[Developer Quickstart prerequisites](includes/quickstart/dev-prereqs.md)]
4428

4529
## Setting up
4630

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
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.
5032

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

53-
#### [Azure CLI](#tab/azure-cli)
35+
[![Open in GitHub Codespaces](https://img.shields.io/static/v1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https://github.com/alexwolfmsft/cosmos-db-mongo-dotnet-quickstart?template=false&quickstart=1&azure-portal=true)
5436

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

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

59-
[!INCLUDE [Powershell - create resource group and resources](./includes/powershell-create-resource-group-and-resource.md)]
41+
[![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/alexwolfmsft/cosmos-db-mongo-dotnet-quickstart)
6042

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

63-
[!INCLUDE [Portal - create resource](./includes/portal-create-resource.md)]
45+
[!INCLUDE[Developer Quickstart setup](includes/quickstart/dev-setup.md)]
6446

6547
---
6648

67-
### Get MongoDB connection string
49+
### Install the client library
6850

69-
#### [Azure CLI](#tab/azure-cli)
51+
The client library is available through NuGet, as the `Microsoft.Azure.Cosmos` package.
7052

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.
7254

73-
#### [PowerShell](#tab/azure-powershell)
55+
```bash
56+
cd ./src/web
57+
```
7458

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

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+
```
9864

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

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

10371
## Object model
10472

0 commit comments

Comments
 (0)