Azure Cosmos DB – Multi model, Globally Distributed Database Service



Introduction to AZURE COSMOS DB

Azure Cosmos DB  is a multi-model database service by design, which can be easily globally distributed. Database engine supports storing of data in documents, key-value pairs and even graphs. Scaling of Cosmos DB across any number of available locations is extremally easy –  just press the appropriate button in the Azure portal. In modern web-based applications low latency is expected by the end users. With Cosmos DB you can store data closer to application users. Database can be distributed and available in 50+ regions. This creates enormous opportunities. Regions management can be involved at any time in application lifecycle.

Based on the above, global distribution of data with Cosmos DB provides a set of benefits such as:

  • support for NoSQL approach for data management,
  • easy management of massive data amounts (read, writes operations close to end users),
  • simplicity of cooperation with mobile, web or even IoT solutions,
  • low latency,
  • high throughput and availability.

For development purpose Microsoft provide Azure Cosmos DB emulator. Functionality is close to native cloud version of Cosmos DB. Developer will be able to create and query JSON documents, deal with collections and test stored procedures or triggers on database level. We need to understand that some features are not fully supported locally. These are among others multi-region replication or scalability.

Later in this post I will try to explain more details about supported data models. All of them use main, cool features provided by Azure Cosmos DB.

Supported data models


This kind of Cosmos DB API provides capabilities to dealing with data for users, which are familiar with SQL queries standards. In general, data is stored as a JSON, but we can query them in easy way with SQL-like queries. Communication is handled by HTTP/HTTPS endpoints which process several requests. Microsoft provide dedicated SDK’s for this kind of API, for most of popular programming languages like .NET, Java, Python or JavaScript. Developers can load dedicated library in their application and start very fast read/write operations directly to Cosmos DB. Sample flow has been shown below.


2. MongoDB API

Existing instances of MongoDB can be migrated to Azure Cosmos DB without huge effort for this activities. Both standards are compatible. If new environment is created, change between native MongoDB instance and Cosmos DB instance (by MongoDB API) comes to change a connection string in application. Existing drivers for application written for MongoDB are fully supported. By design all properties within documents are automatically indexed.

Let’s check, how simple queries for identical documents collection as used in previous point will look like:



As a result, specified sub-JSON contains data will be returned. If query doesn’t return results, empty object will be send as a response to query.

3. Table API

This kind of API can be used by applications prepared natively for close working with Azure Storage tables. Of course Cosmos DB provides some premium capabilities comparing to Storage tables e.g. high availability or global distribution. Migration to new DB source for application doesn’t require changes in code. User can query data in a few ways. Also lot of SDKs are provided by design. Below sample will show how to query data by .NET SDK with LINQ. During execution LINQ query will be translated to ODATA query expression.


4. Cassandra API

Azure Cosmos DB Cassandra API is dedicated data store for applications created for Apache Cassandra. User is able to interact with data via CQL (Cassandra Query Language). In many cases action for changing DB source from Apache Cassandra to Azure Cosmos DB ‘s Cassandra API is just changing a connection string in application. From code perspective integration with Cassandra is realized via dedicated SDK (NuGet -> Install-Package CassandraCSharpDriver). Sample code for connecting to Cassandra cluster from .NET application is presented below.


5. Gremlin API

The last API provided by Azure Cosmos DB (on the day of writing this article 😉) is Gremlin API. This kind of interface can be used for storing and operation on graph data. API supports natively possibilities to graph modeling and traversing. We can query the graphs with millisecond latency and evolve the graph structure and schema in easy way. For querying activities we can use Gremlin or Apache TinkerPop languages. Step by step process from NuGet package installation to run first query is has been shown below.


From the developer perspective, Azure Cosmos DB is very interesting service. Huge range of available APIs allows for using mentioned database in various scenarios. Below you can find information from official Azure Cosmos DB site about availabilities of APIs per programming language.

Source: Azure Cosmos DB Documentation


This post is the last part in our Azure DevOps series. Check out the previous posts:

#1: Azure DevOps Services – cloud based platform for collaborating on code development from Microsoft

#2: Web application development with .NET Core and Azure DevOps



How Do Medium-Sized Companies Adapt Amazon Web Services With Success?

How do companies successfully adapt Amazon Web Services? Which AWS customer did it how? How can Nordcloud help medium-sized companies in particular...


Minimizing AWS Lambda deployment package size in TypeScript

Our Senior Developer Vitalii explains how to significantly reduce the deployment package size of AWS Lambda functions written in TypeScript...


Top 5 Cloud Strategy Tips For the Year 2020

In this chapter of ‘The Role of Transformational Partners in Organization Change’, we introduce Nordcloud’s vision for Cloud Strategy and...

Get in Touch

Let’s discuss how we can help with your cloud journey. Our experts are standing by to talk about your migration, modernisation, development and skills challenges.

SQLSaturday Finland



Join us at SQLSaturday training event on May 11



SQLSaturday is a free training event for Microsoft Data Platform professionals and those wanting to learn about SQL Server, Business Intelligence and Analytics. This event will be held on May 11, 2019, at Microsoft Finland HQ.

Nordcloud is proud to sponsor this event and Mika Sutinen, our Cloud DBA Team Lead, will have a talk about DBA as the Cloud era Data Professional:

Database Administrators have been safeguarding the business critical data assets of the organizations for decades, managing not just the data but often also the infrastructure in the on-premise environments. However, the times are rapidly changing and so are the expectations towards the DBA profession. These new expectations revolve around the ongoing digital transformation across different industries and the DBAs ability to answer to challenges presented by the modern, disruptive technologies.

When it comes to disruptiveness, very few technologies can match the public cloud and as a company working with all the major hyperscalers, Nordcloud has a unique perspective on the requirements on the skillsets needed to manage data in the cloud. Join our session to learn what core DBA skills will still be relevant in the cloud era, and what are the technologies and skills to learn!

Mika’s session is on Saturday at 12:30 PM – 01:30 PM.

Register now!


May 11, 2019


Microsoft Finland HQ,
Keilalahdentie 2-4,
02150 Espoo, Finland



Meet us at Microsoft Ignite 2019

Explore the latest tools and technology – join Nordcloud at Microsoft Ignite in Orlando on November 4-8!


SaaS Business Model and Public Cloud are a Winning Combination for ISVs

Our experts have helped many ISVs to leverage cloud technologies to transition their business from that of a traditional software...


Migrations to MS Azure – Best Practices shared in Poland

Microsoft & Nordcloud Poland on the road.

Get in Touch

Let’s discuss how we can help with your cloud journey. Our experts are standing by to talk about your migration, modernisation, development and skills challenges.