Skip to content

Commit 8f21346

Browse files
authored
Update mongodb.md to mention Azure DocumentDB (#8906)
* Update mongodb.md * Update mongodb.md * added screenshots * Update mongodb.md * Update mongodb.md * Update mongodb.md
1 parent 768af4c commit 8f21346

File tree

9 files changed

+52
-41
lines changed

9 files changed

+52
-41
lines changed
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
24.5 KB
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

docs/azure/mongodb.md

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,74 @@
11
---
22
ContentId: d1187f99-354f-4798-9c19-e432e4ae8572
33
MetaDescription: Working with MongoDB in Visual Studio Code
4-
DateApproved: 11/1/2022
4+
DateApproved: 11/1/2025
55
---
66
# Working with MongoDB
77

8-
Visual Studio Code has great support for working with [MongoDB](https://www.mongodb.com/what-is-mongodb) databases, whether your own instance or in [Azure with MongoDB Atlas](https://www.mongodb.com/cloud/atlas/azure-mongodb?utm_campaign=marketplace&utm_source=&utm_medium=marketplace). With the [MongoDB for VS Code](https://marketplace.visualstudio.com/items?itemName=mongodb.mongodb-vscode) extension, you can create, manage, and query MongoDB databases from within VS Code.
8+
Visual Studio Code has great support for working with [MongoDB](https://www.mongodb.com/what-is-mongodb) databases, whether your own instance or with [Azure DocumentDB (with MongoDB compatibility)](https://learn.microsoft.com/azure/cosmos-db/mongodb/vcore/introduction). With the [DocumentDB for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-documentdb) extension, you can create, manage, and query MongoDB databases from within VS Code.
99

1010
## Install the extension
1111

12-
MongoDB support for VS Code is provided by the [MongoDB for VS Code](https://marketplace.visualstudio.com/items?itemName=mongodb.mongodb-vscode) extension. To install the MongoDB for VS Code extension, open the Extensions view by pressing `kb(workbench.view.extensions)` and search for 'MongoDB' to filter the results. Select the **MongoDB for VS Code** extension.
12+
MongoDB support for VS Code is provided by the [DocumentDB for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-documentdb) extension. To install the DocumentDB for VS Code extension, open the Extensions view by pressing `kb(workbench.view.extensions)` and search for 'DocumentDB' to filter the results. Select the **DocumentDB for VS Code** extension.
1313

14-
![Select MongoDB for VS Code](images/mongodb/install-cosmosdb-extension.png)
14+
![Select DocumentDB for VS Code](images/documentdb/install-documentdb-extension.png)
1515

1616
## Connect to MongoDB
1717

18-
Once you've installed the MongoDB for VS Code extension, you'll notice there is a new **MongoDB** Activity Bar view. Select the MongoDB view and you'll see the MongoDB Explorer.
18+
Once you've installed the DocumentDB for VS Code extension, you'll notice there is a new **DocumentDB** logo in the Activity Bar view. Select the DocumentDB logo and you'll see the Explorer.
1919

20-
![MongoDB explorer](images/mongodb/cosmosdb-explorer.png)
20+
![DocumentDB explorer](images/documentdb/documentdb-explorer.png)
2121

22-
To connect to a MongoDB database:
22+
To connect to a MongoDB-compatible database:
2323

24-
1. Select **Add Connection** in the MongoDB view
24+
1. Select **Add New Connection** in the DocumentDB Connection view
2525

26-
1. Next, choose to connect with a connection string or use advanced connection options:
26+
1. Next, choose to connect with a connection string or use Service Discovery options:
2727

28-
* Select **Connect with Connection String**, and then enter the connection string in the connection string Quick Pick.
28+
* Select **Connection String**, and then enter the connection string in the connection string Quick Pick.
2929

30-
The default connection string for a local MongoDB is `mongodb://127.0.0.1:27017`.
30+
![Database Connection setup](images/documentdb/attach-via-connection-string.png)
3131

32-
![Database Connection setup](images/mongodb/attach-database-account-connection-string.png)
32+
* Select **Service Discovery**, choose your provider, and then select **Save & Connect**.
3333

34-
* Select **Advanced Connection Settings**, enter the connection details, and then select **Save & Connect**.
34+
![Database Connection setup](images/documentdb/attach-via-service-discovery.png)
3535

36-
![Database Connection setup](images/mongodb/attach-database-account.png)
36+
>**Note**: If you're not already signed in to Azure in VS Code, you'll be prompted to do so. This is required to use Service Discovery.
3737
38-
>**Note**: Make sure your MongoDB server (mongod.exe) is running if you are connecting to a local MongoDB server.
38+
Once connected, you can work with the MongoDB server, managing MongoDB Databases, Collections, and Documents.
3939

40-
Once attached, you can work with the MongoDB server, managing MongoDB Databases, Collections, and Documents.
40+
You can expand databases to view their collections in JSON/ Table/ Tree view with their schema and indexes.
4141

42-
![attached MongoDB database](images/mongodb/attached-mongodb-database.png)
42+
![manage mongodb database](images/documentdb/manage-database.png)
4343

44-
You can expand databases to view their collections with their schema and indexes and you can select individual MongoDB Documents to view their JSON.
44+
You can also attach a MongoDB shell to the active connection, simply by right-clicking on the connection itself and selecting **Launch Shell**.
4545

46-
![open mongodb document](images/mongodb/open-document.png)
46+
![MongoDB Connection](images/documentdb/launch-shell.jpeg)
4747

48-
You can also attach a MongoDB shell to the active connection, simply by right-clicking on the connection itself.
48+
>**Note**: Make sure the MongoDB shell (`mongo` or `mongosh`) is [installed](https://docs.mongodb.com/mongodb-shell/install#mdb-shell-install) and is on your path. In the extension's settings, you can choose which shell you are using.
4949
50-
![MongoDB Connection](images/mongodb/connection.png)
50+
## Using Scrapbook
5151

52-
>**Note**: Make sure the MongoDB shell (`mongo` or `mongosh`) [is installed](https://docs.mongodb.com/mongodb-shell/install#mdb-shell-install) and is on your path. In the extension's settings, you can choose which shell you are using.
52+
The **DocumentDB Scrapbook** is one of the most powerful features of this extension. It allows you to write, run, and save MongoDB commands directly within a VS Code editor, helping you prototype queries and scripts
5353

54-
## MongoDB Commands
54+
### Create a New Scrapbook
55+
1. In the DocumentDB Explorer, right-click the desired collection.
5556

56-
There are MongoDB specific commands available in the VS Code **Command Palette** (`kb(workbench.action.showCommands)`) as well as through Explorer context menus.
57+
1. From the menu, click **DocumentDB Scrapbook** and select **New DocumentDB Scrapbook**.
5758

58-
![mongodb commands](images/mongodb/mongodb-commands.png)
59+
![launch documentdb scrapbook](images/documentdb/create-scrapbook.png)
5960

60-
## Using Playgrounds
61+
In a scrapbook, you can reference MongoDB entities and commands and you get rich IntelliSense as you type. Scrapbooks are useful for prototyping database operations and queries. Execute selected lines in the scrapbook queries with **Run Command**.
6162

62-
One of the most powerful features of the VS Code MongoDB integration is **Mongo Playgrounds**. Playgrounds let you create, run, and save MongoDB commands from a VS Code editor. Create a new playground with the **MongoDB: Create MongoDB Playground** command.
63+
![Run scrapbook queries](images/documentdb/run-scrapbook.png)
6364

64-
![new mongo Playground](images/mongodb/new-mongo-scrapbook.png)
65+
## MongoDB on Azure DocumentDB
6566

66-
In a playground, you can reference MongoDB entities and commands and you get rich IntelliSense as you type. Playgrounds are useful for prototyping database operations and queries. Execute selected lines in the playground queries with the **MongoDB: Run Selected Lines From Playground** command.
67-
68-
![mongodb Playground](images/mongodb/scrapbook.png)
69-
70-
![Run Playground queries](images/mongodb/run-playground.png)
71-
72-
## MongoDB on Azure
73-
74-
You can easily create a MongoDB cluster on Azure for **Free** with [MongoDB Atlas](https://www.mongodb.com/cloud/atlas/signup?utm_campaign=marketplace&utm_source=signup&utm_medium=marketplace).
75-
76-
Choose **Create a New Cluster** from the dashboard and choose **Azure** as the Cloud Provider. Once the cluster is created, connect to using the connection string provided by **MongoDB Atlas**.
77-
78-
![Create Azure Cluster](images/mongodb/create-azure-cluster.png)
67+
You can easily create a managed MongoDB cluster on Azure for **Free** with [Azure DocumentDB](https://aka.ms/documentdb).
7968

8069
## Next steps
8170

71+
* [Index Advisor](https://learn.microsoft.com/azure/documentdb/index-advisor) - Learn how to optimize your MongoDB performance with Index Advisor.
8272
* [Azure Extensions](/docs/azure/extensions.md) - The Visual Studio Marketplace has hundreds of VS Code extensions for Azure and the cloud.
8373
* [Deploying to Azure](/docs/azure/deployment.md) - Learn step-by-step how to deploy your application to Azure.
8474
* [Working with Docker](/docs/azure/docker.md) - Put your application in a Docker container for easy reuse and deployment.

0 commit comments

Comments
 (0)