Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
APPLIES TO:
NoSQL
MongoDB
Visual Studio Code is a versatile code editor for Linux, macOS, and Windows, supporting numerous extensions. This quickstart shows you how to connect to Azure Cosmos DB for NoSQL and Azure Cosmos DB for MongoDB (vCore) cluster using Visual Studio Code. It covers performing core database operations, including querying, inserting, updating, and deleting data.
Before you begin, ensure you have the following:
An Azure Cosmos DB account configured with a database and collection for NoSQL API. Use any of these quickstarts below to set up a resource:
To connect and manage data in Azure Cosmos DB within Visual Studio, first install the Azure Databases extension.
The following steps will use the Query Editor to execute a query and view the results of the query:
In the menu for your collection, right-click on the collection to open the Query Editor in Preview.
Run the query provided in the query editor to display your data in Table View:
Explore your data in other supported views:
Within the query editor, view additional query and index metrics to better help optimize your query performance.
For more information on the metric definitions, see the query metrics documentation.
In this tutorial, you've learned how to query data in VS Code, export query results, view query and index metrics for tuning query performance and display data in the multiple supported views. You can now use the Azure Databases VS Code Extension to review real data in your database.
Before you begin, ensure you have the following:
Note
Your password is only used for authentication and is not stored.
Note
In many corporate environments, developer machine IP addresses are hidden due to a VPN or other corporate network settings. In these cases, it is recommended to start with allowing access to all IP addresses by adding the 0.0.0.0 - 255.255.255.255 firewall rule for connection testing initially before refining the allow-list.
Easily manage your databases within Visual Studio Code:
Create and Drop Databases/Collections: Right-click on your account, database, or collection in the resource panel to create or delete databases and collections.
Import from JSON: Quickly import data from JSON files into your collection.
Export Data: Save collections or query results as JSON for backup or sharing.
Real-Time Document Editing: Instantly add, view, edit, and delete documents with real-time updates.
Run and refine your queries seamlessly:
Instant Results: Immediately view query results in your preferred format—Table, JSON, or Tree view.
Execute Queries Directly: Write and execute MongoDB queries with features like syntax highlighting and autocompletion.
Ctrl/Cmd+Enter
in the query editor.Note
Currently, only find filter queries are supported, with expanded query capabilities coming soon.
Explore your data using multiple views for different perspectives:
Table View: Quickly scan data and drill down into nested documents.
Command-line functionality is available:
mongosh
: Execute advanced MongoDB commands directly from Visual Studio Code.Note
The MongoDB shell (mongosh
) is not included with the extension. It must be installed separately and configured manually.
Stay on top of your resources:
View Cluster Details: Check your cluster’s tier, server version, and resource usage.
Manage Tags: Organize your clusters with tags that sync with the Azure Portal.
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Get started with the MongoDB API in Azure Cosmos DB - Training
Learn Azure Cosmos DB for MongoDB basics.
Certification
Microsoft Certified: Azure Cosmos DB Developer Specialty - Certifications
Write efficient queries, create indexing policies, manage, and provision resources in the SQL API and SDK with Microsoft Azure Cosmos DB.
Documentation
Use the Data Explorer to manage your data - Azure Cosmos DB
Learn about the Azure Cosmos DB Data Explorer, a standalone web-based interface that allows you to view and manage the data stored in Azure Cosmos DB.
Create a container in Azure Cosmos DB for NoSQL
Learn how to create a container in Azure Cosmos DB for NoSQL by using Azure portal, .NET, Java, Python, Node.js, and other SDKs.
Quickstart - Azure portal - Azure Cosmos DB for NoSQL
Deploy an Azure Cosmos DB account, database, and container using the Azure portal and Data Explorer.