---
title: Building scalable and efficient data driven apps using Azure Cosmos DB
description: Microsoft Azure Cosmos DB (formerly known by Document DB) is Microsoft’s globally distributed multi-model database service. It is purely Platform as a Service offering (meaning– you don’t need to spin up a VM for Cosmos DB).
image: https://blog.e-zest.com/hubfs/blog-files/Building%20scalable%20and%20efficient%20data%20driven%20apps%20using%20Azure%20Cosmos%20DB-181228.png
---

[![e-Zest logo\_An accion lab company\_Colour](https://blog.e-zest.com/hubfs/images/Logos%20with%20Tagline/Corporate/SVG/e-Zest%20logo_An%20accion%20lab%20company_Colour.svg "e-Zest logo_An accion lab company_Colour")](https://www.e-zest.com/)

- [WORK](https://www.e-zest.com/our-work)
- [SERVICES](https://www.e-zest.com/our-services) 
    - [Product Engineering](https://www.e-zest.com/digital-product-engineering-services)
    - [Enterprise Data Services](https://www.e-zest.com/enterprise-data-services)
    - [Digital Commerce](https://www.e-zest.com/digital-commerce-services)
    - [Digital Operations](https://www.e-zest.com/digital-operations)
    - [Digital Consulting](https://www.e-zest.com/digital-transformation-consulting-services)
    - [Digital Experience Design](https://www.e-zest.com/digital-experience-design)
- [INSIGHTS](https://blog.e-zest.com/)
- [CAREERS](https://www.e-zest.com/careers)
- [ENTERPRISE DATA SERVICES](https://www.e-zest.com/enterprise-data-services)
- [GENERATIVE AI](https://www.e-zest.com/generative-ai)
- [Healthcare](https://healthcare.e-zest.com)
- [Contact Us](https://www.e-zest.com/contact-us)

- ![Elevating Product Engineering with AI and ML](https://blog.e-zest.com/hubfs/Elevating%20Product%20Engineering%20with%20AI%20and%20ML.jpg)

  [BLOGS](https://blog.e-zest.com)
  
  #### Elevating Product Engineering with AI and ML

  As technology evolves and customer choices broaden, there is an increasing ...

  [Read more](https://blog.e-zest.com/elevating-product-engineering-with-ai-and-ml)
- ![e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024](https://blog.e-zest.com/hubfs/e-Zest%20%E2%80%93%20An%20Accion%20Labs%20Company%20-%20Gets%20Recognition%20as%20a%20Contender%20in%20the%20ISG%20Provider%20LensTM%20Study%20on%20Digital%20Engineering%20Services%202024.jpg)

  [NEWS](https://blog.e-zest.com/news)
  
  #### e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024

  We are delighted to announce that e-Zest – An Accion Labs Company has been ...

  [Read more](https://blog.e-zest.com/news/e-zest-an-accion-labs-company-gets-recognition-as-a-contender-in-the-isg-provider-lens-study-on-digital-engineering-services-2024)
- ![e-Zest Solutions supports Digital Pune Mission](https://blog.e-zest.com/hubfs/blog-files/Digital%20Literacy%20Bus%20e-Zest.png)

  [CSR](https://blog.e-zest.com/csr)
  
  #### e-Zest Solutions supports Digital Pune Mission

  **Pune, India:** e-Zest Solutions, a leading digital technology innovation ...

  [Read more](https://blog.e-zest.com/csr/e-zest-solutions-supports-digital-pune-mission)

- [Work](https://www.e-zest.com/our-work)
- [Services](https://www.e-zest.com/our-services)
- [Insights](https://blog.e-zest.com)
- [Careers](https://www.e-zest.com/careers)
- [Enterprise Data](https://www.e-zest.com/enterprise-data-services)
- [Generative AI](https://www.e-zest.com/generative-ai)
- [Innovations](https://www.e-zest.com/innovations)
- [Healthcare](https://healthcare.e-zest.com)
- [About](https://www.e-zest.com/about-us)
- [Contact](https://www.e-zest.com/contact-us)

- [Blog](https://blog.e-zest.com/)
- [News](https://blog.e-zest.com/news)
- [CSR](https://blog.e-zest.com/csr)

- [![Linkedin Icon](https://blog.e-zest.com/hubfs/icons/linkedin_icon_white.svg)](https://www.linkedin.com/company/e-zest-solutions/)
- [![Twitter Icon](https://blog.e-zest.com/hubfs/twitter-logo-silhouette%20(5).svg)](https://twitter.com/ezest)
- [![Facebook Icon](https://blog.e-zest.com/hubfs/facebook-app-logo%20(4).svg)](https://www.facebook.com/61259256638)
- [![Instagram Icon](https://blog.e-zest.com/hubfs/instagram-logo%20(4).svg)](https://www.instagram.com/ezestsolutions/)
- [![Youtube Icon](https://blog.e-zest.com/hubfs/icons/youtube_icon_white.svg)](https://www.youtube.com/user/ezestcorporate)

[![Go to top icon](https://blog.e-zest.com/hubfs/AA%20Assets/top%20button.svg)](https://blog.e-zest.com/building-scalable-and-efficient-data-driven-apps-using-azure-cosmos-db#top)

Hit enter to search or ESC to close

Insights

e-Zest members share technology ideas to foster digital transformation.

- [Blog](https://blog.e-zest.com)
- [Whitepaper](https://blog.e-zest.com/whitepaper)
- [Playbook](https://blog.e-zest.com/playbook)
- [News](https://blog.e-zest.com/news)
- [Innovation](https://blog.e-zest.com/innovation)
- [Media Kit](https://www.e-zest.com/media-kit)

# Building scalable and efficient data driven apps using Azure Cosmos DB

[Vikram Pendse](https://blog.e-zest.com/author/vikram-pendse)  Jan 23, 2019

[Azure](https://blog.e-zest.com/topic/azure) [Microsoft Azure Cosmos DB](https://blog.e-zest.com/topic/microsoft-azure-cosmos-db) [Document DB](https://blog.e-zest.com/topic/document-db)

- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/building-scalable-and-efficient-data-driven-apps-using-azure-cosmos-db&title=&summary=&source=>
- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/building-scalable-and-efficient-data-driven-apps-using-azure-cosmos-db&text=Building%20scalable%20and%20efficient%20data%20driven%20apps%20using%20Azure%20Cosmos%20DB>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/building-scalable-and-efficient-data-driven-apps-using-azure-cosmos-db>
- <https://www.instagram.com/ezestsolutions/?u=https://blog.e-zest.com/building-scalable-and-efficient-data-driven-apps-using-azure-cosmos-db>

Microsoft Azure Cosmos DB (formerly known by Document DB) is Microsoft’s globally distributed multi-model database service. It is purely Platform as a Service offering (meaning– you don’t need to spin up a VM for Cosmos DB). Microsoft started Project “Florence” in the year 2010 released as Document DB service with a vision of document-based database. Azure Storage Table offering is already providing a facility for storing the data in a key-value pair. After embracing open source technologies in Azure, Microsoft also started supporting NoSQL databases like MySQL, Cassandra, Mongo DB and Azure MySQL as well.

Azure Cosmos DB was launched during the year 2016-2017 with a vision of multi-model, globally scalable and turnkey global distribution. Following types of schemas/model of Cosmos DB is supported currently.

![cosmos-db](https://blog.e-zest.com/hs-fs/hubfs/blog-files/cosmos-db.jpg?width=563&name=cosmos-db.jpg)  
All the models can interact with the set of APIs made available from Azure Cosmos DB NuGet package to developers. Overall you can see Cosmos DB as a unified offering supporting multiple models from one service with the help of multiple API sets.

![cosmos-db-1](https://blog.e-zest.com/hs-fs/hubfs/blog-files/cosmos-db-1.jpg?width=467&name=cosmos-db-1.jpg)  
It provides transparent replication of your data across any number of Azure regions. You can elastically scale throughput and storage and take advantage of fast, single-digit-millisecond data \< 10 ms.

**How to create Azure Cosmos DB using Azure portal?**

You can create a new instance of Azure Cosmos DB from Azure portal. You can go to Global Search bar and type “Azure Cosmos DB”.

![create-azure-cosmos-db-account](https://blog.e-zest.com/hs-fs/hubfs/blog-files/create-azure-cosmos-db-account.png?width=600&name=create-azure-cosmos-db-account.png)  
You need to choose subscription, resource group and then give instance name as per the need. Note that the URL of the instance is \<\<Your Name\>\>.documents.azure.com. API drop-down allows you to select the API model as per your business need which can be Core SQL, Table API, Graph etc. By default, Geo-redundancy is enabled but you can disable and re-enable it again later (post provision). Same for multi-region writes, by default, it is disabled but with a single mouse click you can turn on multi-region writes post provision as well. You need to take a judgmental call to enable multi-region write based on the nature and structure of your application. You can also spin the instance in the existing VNET if you have already present. If you are spinning instance for demonstration purpose only, then you can ignore network section. Once you hit review + create you will see a new instance of Azure Cosmos DB getting spin for you. This entire activity can be done programmatically as well with the APIs. If you choose SQL API then you can also fire SQL queries on your schema/document collection.

To access Azure Cosmos DB from your code, you can add Cosmos DB endpoint and key in your app.config as shown below–

*\<appSettings\>*  
 *\<!--Add Cosmos DB Endpoint URL--\>*  
 *\<add key="CosmoEndpoint" value="https://xyz.documents.azure.com:443/"/\>*  
 *\<!--Add Primary Key--\>*  
 *\<add key="CosmoMasterKey" value ="YourKey"/\>*  
 *\</appSettings\>*

*You can call this connection from your main function or any module like an example shown below –*  
*Task.Run(async () =\>*  
 *{*  
 *var endpoint = ConfigurationSettings.AppSettings\["CosmoEndpoint"\];*  
 *var masterKey = ConfigurationSettings.AppSettings\["CosmoMasterKey"\];*  
 *using (var client = new DocumentClient(new Uri(endpoint), masterKey))*  
 *{*  
 *Console.WriteLine("\\r\\n-- Querying Document (JSON) --");*  
 *var databaseDefinition = "\<Your Schema Name\>";*  
 *var collectionDefinition = "\<Your Collection Name\>";*

*var document = new FeedOptions { EnableCrossPartitionQuery = true };*

 *var response = client.CreateDocumentQuery(UriFactory.CreateDocumentCollectionUri(databaseDefinition, collectionDefinition),*  
 *"select \* from c", document).ToList();*  
 *foreach (var item in response)*  
 *{*  
 *Console.WriteLine(item);*  
 *Console.WriteLine("\\r\\n");*  
 *}*  
 *Console.ReadKey();*  
 *}*

 *}).Wait();*

Request Units (RU) is a rate-based currency. This abstracts physical resources for performing requests.

1 RU = 1 Read of 1 KB Document

Reads under \< 10 ms and indexed writes \< 10 ms at the 99th percentile, within the same Azure region. Customers can elastically scale throughput of a container by programmatically provisioning RU/s (and/or RU/m) on a container. Elastically scaling throughput using horizontally partitioning of resources requires each resource partition to deliver the portion of the overall throughput for a given budget of system resources.

**Scenarios where Azure Cosmos DB can be used**

There are plenty of scenarios where Azure Cosmos DB can be used, below is the diagrammatic representation of some of the use cases:

1. IoT devices sending data and high-fidelity events stored in Cosmos DB
2. App services connected to Azure Cosmos DB (Web App, Mobile App and API App)
3. Session persistence in e-commerce type of apps

**![azure-cosmos-db-scenarios](https://blog.e-zest.com/hs-fs/hubfs/blog-files/azure-cosmos-db-scenarios.png?width=600&name=azure-cosmos-db-scenarios.png)  
Moving from Azure Table Storage to Azure Cosmos DB and Migration Tool**

The advantage of moving from Azure Table Storage to Azure Cosmos DB is that you naturally get all the amazing features and SLAs of Azure Cosmos DB. Also, it is easy to access and query the data. Practically you don’t need to do much of the code changes since the way to access (even from API code level point of view) is similar to Azure Storage. So, you can get the key-value storage benefit of Azure Table Storage plus the turnkey scalability, geo-replication and multi-write in a single digit and other SLAs at a low price. Following is the quick sample which showcases how the code is similar to Azure Table Storage if you want to access the same set of schemas from Azure Cosmos DB.

*using Microsoft.Azure.Storage;*  
*using Microsoft.Azure.CosmosDB.Table;*

 *var connectionString = "DefaultEndpointsProtocol=https;AccountName=\<\<Your Name\>\>;AccountKey=\<\<YourKey\>\>;TableEndpoint=https://yourname.table.cosmosdb.azure.com:443/;";*  
 *CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);*  
 *CloudTableClient tableClient = storageAccount.CreateCloudTableClient();*

**Migration Tool**

Microsoft provides Document DB data migration tool which allows you to seamlessly migrate the following data sources to Azure Cosmos DB multi-model:

- JSON files
- MongoDB
- MongoDB Export files
- SQL Server
- CSV files
- Azure Table storage
- Amazon DynamoDB
- Blob
- Azure Cosmos DB collections
- HBase
- Azure Cosmos DB bulk import
- Azure Cosmos DB sequential record import

 This is a free tool and can be downloaded from [here](https://github.com/azure/azure-documentdb-datamigrationtool)

![documentDB-data-migration-tool](https://blog.e-zest.com/hs-fs/hubfs/blog-files/documentDB-data-migration-tool.jpg?width=600&name=documentDB-data-migration-tool.jpg)  
**Key highlights of Azure Cosmos DB**

- Linearizability (once the operation is complete, it will be visible to all)
- 99.99% availability and low latency
- Predictable consistency for a session, high read throughput plus low latency
- Reads will never see out of order writes (no gaps)
- Potential for out of order reads
- Lowest cost for reads of all consistency levels

**Summary**

Azure Cosmos DB started as “Project Florence” in late 2010, which eventually grew into Azure Document DB is the first and only globally distributed database service today which offers comprehensive Service Level Agreements (SLAs) accounting multiple factors like throughput, latency at the 99th percentile, availability, and consistency. Azure Cosmos DB is built upon the solid backbone of “Service Fabric” technology which is a great distributed systems infrastructure.

- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/building-scalable-and-efficient-data-driven-apps-using-azure-cosmos-db&text=Building%20scalable%20and%20efficient%20data%20driven%20apps%20using%20Azure%20Cosmos%20DB>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/building-scalable-and-efficient-data-driven-apps-using-azure-cosmos-db>
- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/building-scalable-and-efficient-data-driven-apps-using-azure-cosmos-db&title=&summary=&source=>

### Similar Blog

[![PowerShell – Assigning Tags to Azure Resources using Excel Sheet](https://blog.e-zest.com/hubfs/Banners/PowerShell%20%E2%80%93%20Assign%20Tags%20to%20Azure%20Resources%20using%20Excel%20Sheet%20V2-08_2x.jpg) PowerShell – Assigning Tags to Azure Resources using Excel Sheet Prerequisite By Sourabh Majali Aug 03, 2023](https://blog.e-zest.com/powershell-assigning-tags-to-azure-resources-using-excel-sheet)

[![Transform Your Data Warehouse with Azure Synapse Analytics](https://blog.e-zest.com/hubfs/Azure%20Synapse%20Analytics-%201280px%20by%20667px.jpg) Transform Your Data Warehouse with Azure Synapse Analytics Today, practically all businesses rely on data to run their operations, which raises the demand for enabling data-driven insights ... By Mohini Wable Oct 13, 2022](https://blog.e-zest.com/transform-your-data-warehouse-with-azure-synapse-analytics)

[![Implementing Web Application Firewall (WAF) to an Application](https://blog.e-zest.com/hubfs/blog-files/Implementing%20Web%20Application%20Firewall%20(WAF)%20in%20an%20Application-190822.png) Implementing Web Application Firewall (WAF) to an Application **Why do we need WAF?** Attacks against web servers are the most common among the issues in cybersecurity. Servers are often ... By Sourabh Majali Aug 26, 2019](https://blog.e-zest.com/implementing-web-application-firewall-to-an-application)

[![Inspiring times at Microsoft Inspire 2019](https://blog.e-zest.com/hubfs/blog-files/Inspire-blog-graphic2-190711.png) Inspiring times at Microsoft Inspire 2019 The month of July has been a month of reunion, networking, sharing ideas and creating business opportunities through ... By Girish Chandra Jul 11, 2019](https://blog.e-zest.com/inspiring-times-at-microsoft-inspire-2019)

[![Containerized Magento Application Deployed on Azure Web App for Containers](https://blog.e-zest.com/hubfs/blog-files/Containerized%20Magento%20Application%20Deployed%20on%20Azure%20Web%20App%20for%20Containers-190530.png) Containerized Magento Application Deployed on Azure Web App for Containers Magento is an open source technology for e-Commerce platform. The platform makes it flexible and easy for merchants to control ... By Pramod Farate May 30, 2019](https://blog.e-zest.com/containerized-magento-application-deployed-on-azure-web-app-for-containers)

[![The power of Mixed Reality (MR) and Azure AI Services](https://blog.e-zest.com/hubfs/blog-files/The%20power%20of%20Mixed%20Reality%20and%20Azure%20AI%20Services-190807.png) The power of Mixed Reality (MR) and Azure AI Services The power of Mixed Reality combined with holographic technology and Azure AI services could be well on the verge of transforming ... By Vikram Pendse Aug 12, 2019](https://blog.e-zest.com/the-power-of-mixed-reality-mr-and-azure-ai-services)

[![Penetration Testing in Microsoft Azure](https://blog.e-zest.com/hubfs/penetration-testing-in-microsoft-azure.png) Penetration Testing in Microsoft Azure Microsoft Azure, one of the leading cloud platforms, offers individual customers, startups and large enterprises an easy way to ... By Vikram Pendse Sep 30, 2018](https://blog.e-zest.com/penetration-testing-in-microsoft-azure)

[![The complete round-up of SharePoint Server 2019](https://blog.e-zest.com/hubfs/SharePoint%20Server%202019.png) The complete round-up of SharePoint Server 2019 When SharePoint 2019 was first announced at Ignite last year, Microsoft didn't share many details with its curious followers. All ... By Vikram Pendse May 24, 2018](https://blog.e-zest.com/the-complete-round-up-of-sharepoint-server-2019)

[![Managing Azure VM-level Backup](https://blog.e-zest.com/hubfs/Managing%20Azure%20VM-level%20Backup.jpg) Managing Azure VM-level Backup Backups are very crucial in any IT related operations. They are your fallback mechanism, just in case things go southwards. In ... By Vikram Pendse Dec 09, 2017](https://blog.e-zest.com/managing-azure-vm-level-backup)

## Helping Organizations Thrive in the Digital Age

[Contact Us](https://www.e-zest.com/contact-us)

- [About](https://www.e-zest.com/about-us)
- [Services](https://www.e-zest.com/our-services)
- [Work](https://www.e-zest.com/our-work)
- [Insights](https://blog.e-zest.com/)
- [Healthcare](https://healthcare.e-zest.com/)
- [Accion Labs](https://www.accionlabs.com/)

- <https://www.linkedin.com/company/e-zest-solutions/>
- <https://twitter.com/ezest>
- <https://www.facebook.com/eZest/>
- <https://www.instagram.com/ezestsolutions/>
- <https://www.youtube.com/user/ezestcorporate>

- Dallas
- Detroit
- Hannover
- Vienna
- London
- Pune

 © 2025 e-Zest Solutions

- [Privacy Policy](https://www.e-zest.com/privacypolicy)
- [Cookie Policy](https://www.e-zest.com/cookie-policy)

 Contact us

 Contact us

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.