What is Azure Cosmos DB and how do you get started using it?

By | February 10, 2018

Azure Cosmos DB is the world’s first globally distributed multi-model database service, that lets you elastically scale throughput and storage across any number of geographical regions while guaranteeing low latency, high availability and consistency. It was launched in May 2017 and was recently honored in InfoWorld’s 2018 Technology of the Year Awards.

Azure Cosmos DB offers multiple models (APIs):

  • SQL API, a JSON document database service that supports SQL queries. This is compatible with the former Azure DocumentDB.
  • MongoDB API, compatible with existing Mongo DB libraries, drivers, tools and applications.
  • Cassandra API, compatible with existing Apache Cassandra libraries, drivers, tools and applications.
  • Azure Table API, a key-value database service compatible with existing Azure Table Storage.
  • Gremlin (graph) API, a graph database service supporting Apache Tinkerpop’s graph traversal language, Gremlin.
  • Additional models are coming soon (according to Microsoft).

You can easily distribute your data globally by simply clicking on a map. The Azure Cosmos DB client API can automatically send requests to your preferred location.

Azure Cosmos DB Global Distribution

What also makes Azure Cosmos DB different from other distributed database services is that it offers five different consistency models:

Azure Cosmos DB consistency models


  • Strong consistency guarantees that reads from anywhere in the world always return the latest version of information. When using strong consistency, you cannot associate your Azure Cosmos DB account with more than one region.
  • Bounded-staleness guarantees that reads from anywhere in the world lags behind writes by a maximum lag (in seconds or operations).
  • Session is the most widely used consistency level. It comes with a read-your-own-writes guarantee, which means a client will never get anything older than the last version of information that client wrote.
  • Consistent prefix guarantees that clients will never see data in the wrong order.
  • Eventual consistency guarantees that all locations (replicas) will eventually converge, but there are no guarantees again out of order reads.

Some other great features that Azure Cosmos DB supports are:

  • Stored Procedures
  • User Defined Functions
  • Triggers
  • ACID (within a single stored procedure or trigger)
  • Service Level Agreement (99.99% availability for single region or 99.999% read availability for multi-region accounts). Guaranteed low latencies (in the millisecond range).
  • Scales your database storage fully automatically as it grows.
  • Scalable performance. You are guaranteed to get the performance (throughput) that you reserve.

Use cases

Azure Cosmos DB is useful for a very wide range of applications, but in some cases, Azure Cosmos DB is extra beneficial:

  • Mobile applications, web applications or client applications that run globally
  • Internet of Things services
  • Applications that contains legacy code that already uses any of the supported APIs (Mongo DB, Cassandra or Gremlin).
  • When the application or service has to be really scalable
  • When there is a need for elasticity (to handle quick growth)
  • When low latency is required
  • When both data consistency and high scalability are important
  • When high availability is important

Getting started


First you will need an account:

  • Microsoft provides free Azure Cosmos DB databases that work for a limited time. When the trial expires you can always delete your database and create a new.
  • If you are new to Azure, you can sign up for a trial account and get free access for 12 months (with limited database size and throughput).
  • Or you can just create an account in the Azure Portal. There is no fixed fee, only a pay-as-you-go fee when you start using it.

Follow a tutorial

There are many 5-minute quickstarts available for getting started with your programming language and your preferred API:

There are also plenty of samples on GitHub.

Further reading

I recommend reading a technical overview of Azure Cosmos DB. It explains the architecture behind Azure Cosmos DB.

Also there is the Azure Cosmos DB FAQ, which answers many questions.

Finally, there are many useful videos available on Channel 9.

Good luck!