Use MongoDB Compass to connect to Azure Cosmos DB's API for MongoDB
APPLIES TO: MongoDB
This tutorial demonstrates how to use MongoDB Compass when storing and/or managing data in Azure Cosmos DB. We use the Azure Cosmos DB's API for MongoDB for this walk-through. For those of you unfamiliar, Compass is a GUI for MongoDB. It is commonly used to visualize your data, run ad-hoc queries, along with managing your data.
Azure Cosmos DB is Microsoft's globally distributed multi-model database service. You can quickly create and query document, key/value, and graph databases, all of which benefit from the global distribution and horizontal scale capabilities at the core of Azure Cosmos DB.
Prerequisites
To connect to your Azure Cosmos DB account using MongoDB Compass, you must:
- Download and install Compass
- Have your Azure Cosmos DB connection string information
Connect to Azure Cosmos DB's API for MongoDB
To connect your Azure Cosmos DB account to Compass, you can follow the below steps:
Retrieve the connection information for your Azure Cosmos DB account configured with Azure Cosmos DB's API MongoDB using the instructions here.
Click on the button that says Copy to clipboard next to your Primary/Secondary connection string in Azure Cosmos DB. Clicking this button will copy your entire connection string to your clipboard.
Open Compass on your desktop/machine and click on Connect and then Connect to....
Compass will automatically detect a connection string in the clipboard, and will prompt to ask whether you wish to use that to connect. Click on Yes as shown in the screenshot below.
Note
If Compass does not automatically detect your connection string, you can still manually paste it into the application.
Upon clicking Yes in the above step, your details from the connection string will be automatically populated. Remove the value automatically populated in the Replica Set Name field to ensure that is left blank.
Click on Connect at the bottom of the page. Your Azure Cosmos DB account and databases should now be visible within MongoDB Compass.
Next steps
- Learn how to use Studio 3T with Azure Cosmos DB's API for MongoDB.
- Explore MongoDB samples with Azure Cosmos DB's API for MongoDB.
- Trying to do capacity planning for a migration to Azure Cosmos DB? You can use information about your existing database cluster for capacity planning.
- If all you know is the number of vcores and servers in your existing database cluster, read about estimating request units using vCores or vCPUs
- If you know typical request rates for your current database workload, read about estimating request units using Azure Cosmos DB capacity planner