Introduction to Azure Cosmos DB for MongoDB


Azure Cosmos DB is a fully managed NoSQL and relational database for modern app development.

Azure Cosmos DB for MongoDB makes it easy to use Azure Cosmos DB as if it were a MongoDB database. You can use your existing MongoDB skills and continue to use your favorite MongoDB drivers, SDKs, and tools by pointing your application to the connection string for your account using the API for MongoDB.


Want to try the API for MongoDB with no commitment? Create an Azure Cosmos DB account using Try Azure Cosmos DB for free.

API for MongoDB benefits

The API for MongoDB has added benefits of being built on Azure Cosmos DB when compared to service offerings such as MongoDB Atlas:

  • Instantaneous scalability: With the Autoscale feature, your database can scale up/down with zero warmup period.

  • Automatic and transparent sharding: The API for MongoDB manages all of the infrastructure for you. This management includes sharding and optimizing the number of shards. Other MongoDB offerings such as MongoDB Atlas, require you to specify and manage sharding to horizontally scale. This automation gives you more time to focus on developing applications for your users.

  • Five 9's of availability: 99.999% availability is easily configurable to ensure your data is always there for you.

  • Cost efficient, granular, unlimited scalability: Sharded collections can scale to any size, unlike other MongoDB service offerings. APIs for MongoDB users are running databases with over 600 TB of storage today. Scaling is done in a cost-efficient manner unlike other MongoDB service offerings. The Azure Cosmos DB platform can scale in increments as small as 1/100th of a VM due to economies of scale and resource governance.

  • Serverless deployments: Unlike MongoDB Atlas, the API for MongoDB is a cloud native database that offers a serverless capacity mode. With Serverless, you're only charged per operation, and don't pay for the database when you don't use it.

  • Free Tier: With Azure Cosmos DB free tier, you'll get the first 1000 RU/s and 25 GB of storage in your account for free forever, applied at the account level.

  • Upgrades take seconds: All API versions are contained within one codebase, making version changes as simple as flipping a switch, with zero downtime.

  • Real time analytics (HTAP) at any scale: The API for MongoDB offers the ability to run complex analytical queries. Use cases for these queries include business intelligence that can run against your database data in real time with no effect on your database. This analysis is fast and inexpensive, due to the cloud native analytical columnar store being utilized, with no ETL pipelines. Learn more about the Azure Synapse Link.

How the API for MongoDB works

The API for MongoDB implements the wire protocol for MongoDB. This implementation allows transparent compatibility with native MongoDB client SDKs, drivers, and tools. Azure Cosmos DB doesn't host the MongoDB database engine. Any MongoDB client driver compatible with the API version you're using should be able to connect, with no special configuration.


This article describes a feature of Azure Cosmos DB that provides wire protocol compatibility with MongoDB databases. Microsoft does not run MongoDB databases to provide this service. Azure Cosmos DB is not affiliated with MongoDB, Inc.

MongoDB feature compatibility

The API for MongoDB is compatible with the following MongoDB server versions:

Choosing a server version

All the APIs for MongoDB versions run on the same codebase, making upgrades a simple task that can be completed in seconds with zero downtime. Azure Cosmos DB simply flips a few feature flags to go from one version to another. The feature flags also enable continued support for older API versions such as 3.2 and 3.6. You can choose the server version that works best for you.

What you need to know to get started

  • You aren't billed for virtual machines in a cluster. Pricing is based on throughput in request units (RUs) configured on a per database or per collection basis. The first 1000 RUs per second are free with Free Tier.

  • There are three ways to deploy the API for MongoDB:

    • Provisioned throughput: Set a RU/sec number and change it manually. This model best fits consistent workloads.

    • Autoscale: Set an upper bound on the throughput you need. Throughput instantly scales to match your needs. This model best fits workloads that change frequently and optimizes their costs.

    • Serverless: Only pay for the throughput you use, period. This model best fits dev/test workloads.

  • Sharded cluster performance is dependent on the shard key you choose when creating a collection. Choose a shard key carefully to ensure that your data is evenly distributed across shards.

Next steps

Want to learn more?