The Wayback Machine - https://web.archive.org/web/20240930161553/https://www.geeksforgeeks.org/introduction-to-azure-cosmos-db/
Open In App

Introduction to Azure Cosmos DB

Last Updated : 30 Mar, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

CosmosDB is a NoSQL database by Azure. In this article, We’ll discuss high-level horizontal scaling, replication, partitioning, and database schema. And then we’ll dive into some of the data models that Cosmos DB supports. So, let’s get started. 

Applications used to be relatively simple. We would have an app, an API layer, and a slow drip of data dropping into our database. Now occasionally, we may have needed to surface that data and lookup device information in a catalog or look up an appointment on a calendar. But often the data sat in the database until it was called on however many days, months, or even years later.

In the age of big data, where data sets have now grown from a few gigabytes to tens of gigabytes and even petabytes for some of our most demanding applications. Data is pouring into our databases and applications are demanding that data be surfaced quickly and frequently to fulfill user expectations of a personalized and fast application experience. 

Now, Azure Cosmos DB has boomed as the answer to the big data demands of cloud-native applications. Because non-relational or NoSQL databases like Azure Cosmos DB scale horizontally rather than vertically, we can essentially uncap the throughput and volume of data in our database. Rather than upgrading hardware on a single node to serve requests faster, Cosmos DB distributes that work across multiple nodes so requests can be served concurrently. Scaling out verse scaling up is the biggest difference between relational databases and non-relational databases like Cosmos DB.

Horizontal scaling or scaling out is the consequence of two techniques: partitioning and replication. Now there are two kinds of partitions in Azure Cosmos DB: logical and physical.

A physical partition is an actual unit of storage that physically sits in the Azure region that we dictate. This is a piece of hardware holding our data somewhere in the cloud. Logical partitions are logical groups across items within our data set, and we reference these groups through something called a partition key. The partition key is important because it tells our database engine where to look for our data. Choosing the right partition key is a simple but important part of optimizing our database, and when done correctly, we can expect to see performance gains proportional to the additional number of nodes serving our requests. Put simply, partitioning our data across nodes improves database latency and throughput. 

Now like with partitions, there are also two kinds of replication in Cosmos DB: replication within a region and geo-replication outside of a region. Now within a region, our data is replicated four times as a redundancy measure, improving fault tolerance. Outside of a region, our data is geo-replicated into any additional Azure regions we select resulting in higher availability. Replication within a single region increases fault tolerance. Geo-replication into additional Azure regions increases availability. Now these two techniques, replication, and partitioning are in large part what makes horizontal scaling possible. 

Now what makes NoSQL attractive to modern op devs, performance and availability gains aside, are the relaxed constraints around keeping our data relational. Cosmos DB is schema-less meaning structure is not enforced on any data entering the database. Two documents in the same collection can have a completely different structure without any issue. And as a result, developers can and structurally variable data into the database and later build, change or add functionality as use for that data evolves. This combination of flexible schema and horizontal scaling is what makes NoSQL different.

 Cosmos DB makes it easy to ingest and resurface high volumes of variable data without compromising on performance or availability. In addition to flexible schema, Cosmos also supports multiple data models. Cosmos has been built to be the hub for all NoSQL data types. 

Cosmos has a SQL API with document and key-value support built-in. Documents and key-value pairs go hand in hand in most NoSQL databases because documents are just key-value pairs in which the key is a document and the value is a JSON object that we just call a document. Now to reap the performance benefits of a true key-value store, with a SQL API, we can do fast and cost-effective point reads as long as we know the document ID and partition key for the item we want to read. This is a great optimization tool for applications. The next data model, the graph data model, is accessible via the Gremlin API, which uses edges and vertices as well as a traversal to model complex systems with many to many relationships. Think of a graph as a web or a network of nodes. The API is for Mongo DB and Cassandra respectively, are created so that developers familiar with both open-source databases can work with the tools, SDKs, and drivers that they’re already used to.API for Mongo DB also leverages documents, and Cassandra API is a wide-column store, which orients data efficiently in columns instead of rows to optimize for analytics. That’s it for our first episode. Cosmos DB is our horizontally scaling, NoSQL database. Partitioning makes it fast, replication makes it available and flexible schema makes it simple to work with.


Previous Article
Next Article

Similar Reads

Introduction to Azure Cosmos DB for Apache Gremlin
Pre-requisite: Microsoft Cosmos DB Microsoft offers Azure Cosmos DB, a multi-model, globally distributed database service. It is the first cloud database to offer comprehensive support for the Apache Gremlin graph API, making it the perfect choice for developers who want to build highly-scalable and reliable applications backed by a graph database.
8 min read
Microsoft Azure - Notebooks in Cosmos DB
In this article we will learn about how to use Azure Cosmos DB built-in notebooks. So, the easiest way to get started is from the data explorer. You can go to the gallery tab, and so you have official samples written by the Cosmos DB team as well as samples submitted by users in the public gallery. Azure has notebooks written for both C# and Python
5 min read
Microsoft Azure - Choosing a Partition Key in Cosmos DB
Azure Cosmos DB makes use of partitioning to scale individual containers in a database subsequently enhancing the performance needs of your application. In partitioning, the items in a container are divided into distinct subsets called logical partitions. Logical partitions are created based on the value of a partition key that is linked with each
3 min read
Working with Azure Cosmos DB and JavaScript SDK
Azure Cosmos DB is a No SQL database service that supports flexible schemas and hierarchical data for modern applications. It is a globally distributed, multi-model database service that supports document, key-value, wide-column, and graph databases. Azure Cosmos DB service takes care of database administration, updates, patching, and scaling. It a
10 min read
How to Setup Azure Cosmos DB?
Azure Cosmos DB is a managed database service that provides high availability and scalability to applications. It provides support for various NoSQL databases. It is available in cross regions hence providing high throughput. In this article, we will set up Azure cosmos DB for NoSQL. So let's see how to set it up. Instead of you maintaining the Dat
4 min read
API In Azure Cosmos DB
Azure Cosmos DB, a multi-model database service provided globally by Microsoft, allows users to increase the storage and throughput across multiple locations elastically and autonomously. Azure Cosmos DB provides native support for several data formats, including document, key-value, graph, and columnar, as well as turnkey global dissemination, ela
10 min read
How To Use Azure Cosmos DB To Create And Manage NoSQL Databases
Azure Cosmos DB is a multi-model, globally distributed database service provided by Microsoft Azure. It comes as a fully managed database service with turnkey global distribution and transparent multi-master replication. You can run globally distributed, low-latency operational and analytics words and AI on transactional data within your database.
4 min read
What is Partition Key In Azure Cosmos DB
The Partition Key in Azure Cosmos DB is an important factor for distributing data efficiently across the database's physical partitions. The partition key plays an important role in storing and accessing data and the partition key makes the filtering data more efficient and optimized. In this article we will discuss the partition key in Azure Cosmo
7 min read
Microsoft Azure - Get Azure VM Properties using Azure PowerShell
The purpose of using the Azure PowerShell Commands is to quickly analyze the overall properties of VM/VMs at once the filtering the with select and where conditions. To find the properties of an Azure VM, you can perform the following commands in Azure Cloud Shell to get the details. Command: Get-AzVM Output: 1. Get all properties of an Azure Virtu
2 min read
Microsoft Azure - RDP to Azure Virtual Machines using Azure Bastion
In this article, we will learn how to do RDP(Remote Desktop Protocol) / SSH(Secure Shell) Connection to an Azure VM using Azure Bastion. First, let's discuss Azure Bastion. The Azure Bastion service is a fully platform-managed PaaS service that you provision inside your virtual network. It provides secure and seamless RDP/SSH connectivity to your v
3 min read
Microsoft Azure - Configure Azure SQL with Azure CLI
In this article, we're going to take a closer look at how you can configure something like connectivity using the Azure CLI. What we have here is we are in Azure Data Studio and similar to the SQL notebook we are actually using a PowerShell notebook. That just means all our code cells are going to run PowerShell and we are just connecting to localh
4 min read
Microsoft Azure - Get CPU Utilization Data of a Azure VM in Azure Portal
Azure Virtual Machines (VM) is one of several types of on-demand, scalable computing resources that Azure offers. In this article, we will look into the process of getting the CPU Utilization data of an Azure VM in Azure Portal. Implementation: Follow the steps to get the CPU Utilization of an Azure VM in Azure Portal: Step 1: Log in to your Azure
2 min read
Microsoft Azure - Archive Azure VM to Azure Storage Account
In this article, we will be implementing a solution to archive a select azure VM snapshot to a select storage account for archiving using azure cloud shell. For implementation, we will be using Azure CLI commands. Prerequisite:VM SnapshotA storage account is neededUser needs "Storage Blob Contributor Data" IAM Role Access on Archiving Storage Accou
2 min read
Microsoft Azure - Check Status of Azure VM using Azure PowerShell
The following Azure PowerShell command helps you to find the Azure VM Config and properties details of Os Name, Os Version, Hyper V Generation, Disks properties, Extensions properties of Type Handler Version, Status and Message, VM Agents properties of Type Handler Version, Status and Message and also VM Power Status Codes, Messages, Plugins, Time
3 min read
Microsoft Azure - Azure VM Disk Space in Percentage using Azure KQL
Here we'll be using the Azure Insights Metric Query to find the free disk space in percentage using KQL. The purpose of this query is to find disk drive free space of all the Azure VMs without logging into every server. You can Run the following KQL log Queries in Azure Monitor or Azure VM Logs or Log Analytics Workspace. Note: VM Insights Agent sh
1 min read
Microsoft Azure - Enable Azure Monitor VM Insights Agent For Azure VM
Azure Monitor VM Insights Agent enables you to get more visibility into the health and performance of your Azure VM. Here we'll see how we can enable Azure Monitor VM Insights to monitor the health, performance, and dependencies of azure virtual machines. Implementation: Follow the below steps to enable Azure Monitor VM insights agents for an Azure
2 min read
Microsoft Azure - Azure CLI Commands to Manage Azure VMs
Azure Command-line interface is used to manage or to create Azure resources. By using the simple AZ CLI command we can manage Azure VM quickly and at a Scale. Let's get started by using a few important Azure CLI commands to manage Azure Virtual Machines. 1. Start a Specific Stopped VM in a Select Resource Group Use the below command to start a spec
2 min read
Microsoft Azure - Manage Azure VMs using Azure PowerShell Commands
Here we are using Azure PS Commands to manage azure resources from Azure Cloud Shell or by using Windows PowerShell. By using the simple AZ PS command we can manage Azure VM Quicks without any efforts of navigating in Azure Portal and at Scale. Let's get started by using the major Azure PS commands to manage Azure Virtual Machine. 1. Start a Specif
2 min read
Microsoft Azure - Query Azure Storage Logs in Azure Monitor Log Analytics
Pre-requisite:- Azure Log Analytics is a tool offered by Azure, which is used to edit and run log queries against data in the Azure Monitor Logs store and helps interactively analyze their results. One can easily use Log Analytics queries to retrieve records that match particular criteria, identify trends, analyze patterns, and provide various insi
5 min read
Microsoft Azure - Install Azure Command Line Interface (Azure CLI)
Azure CLI is a very powerful tool that can be used to automate tasks, create, update, manage or delete azure resources or to troubleshoot problems with az module cmdlets. By installing az modules on your system or on your development system you and your development team can easily create, update or manage Azure AD and Azure resources such as manage
4 min read
Microsoft Azure - Introduction to Azure Digital Twins
In this article, we will learn how to get started with Azure Digital Twins. With Azure Digital Twins, you can model your real-world environment, including buildings, IoT sensors, and people to keep track of it, monitor it, and design it. Let's see how that works. First, we need to create an Azure Digital Twins service in Azure. Let's search for Dig
3 min read
Microsoft Azure - Introduction to Azure Sentinel
Azure Sentinel is a cloud-native security information and event management (SIEM) solution offered by Microsoft Azure. It provides intelligent security analytics and threat intelligence across the enterprise, helping organizations detect, investigate, and respond to security threats quickly and effectively. Here are some key features and benefits o
4 min read
Microsoft Azure - Introduction to Azure VM Extension
In this article, we will look into how the Azure Virtual Machines extension for Visual Studio Code works. Let's use Visual Studio Code to manage our virtual machines in Azure. Follow the below steps to use the Azure VM extension in VS Code: Step 1: First, go to the "Extensions" tab and search for Azure Virtual Machines. Then install it. After it is
2 min read
Microsoft Azure - Introduction to Azure Kung Fu Toolkit
In this article, we will learn about the Azure Kung Fu Toolkit. The Azure Kung Fu toolkit contains tons of practical scripts and examples for the Azure CLI. The below images shows the GitHub page of the Azure Kung Fu Toolkit. You can download the toolkit from here, and run and use the scripts on your local machine. You can also contribute to it as
3 min read
Microsoft Azure - Introduction to Azure SQL Database
Azure SQL Database is a database built for modern Cloud applications. Developers and clients opt for Azure SQL for one or more of the below-mentioned reasons: If they want to build multi-tenanted software as a service type of application, elastic pools are a great option for the same.If they have a database and they don't want to have to choose bet
3 min read
Microsoft Azure - Introduction to Azure SQL
This article aims to explain what is Azure SQL and how to translate your existing SQL Server expertise to Azure SQL. This is going to include Azure SQL database and Azure SQL Managed Instance. It also aims to explain the foundational knowledge of what to use when, as well as how to configure, monitor, and troubleshoot. The key feature of SQL Server
5 min read
Microsoft Azure - Introduction to Azure Database For MySQL
This article aims to provide introductory knowledge of the Azure Database for MySQL. By the end of this read, users will be able to Understand the basic idea of Azure Database for MYSQL, and how it differs from traditional MYSQL databases.Understand business requirements and benefits of this service.Understand how to deploy the MYSQL server in the
3 min read
Microsoft Azure - Introduction to Azure Arc
In this article, we will learn how to get started with Azure Arc in the Azure Portal. Azure Arc is a set of offerings that allow you to bring Azure management anywhere. And you can basically take resources that don't run on Azure like Kubernetes clusters or virtual machines or what you can bring them into Azure us familiar tools and management to t
4 min read
Microsoft Azure - Introduction to Azure Data Factory
Azure data factory as commonly known as ADF is an ETL(Extract-Transform- load ) Tool to integrate data from various sources of various formats and sizes together, in other words, It is a fully managed, serverless data integration solution for ingesting, and preparing, and transforming all your data at scale. The pipelines of Azure data factory are
9 min read
Microsoft Azure - Azure Managed Disk State Details using PowerShell
In this article, we will try to understand how we can fetch the VM Disk State by using the Azure PowerShell Commands. With the help of the Azure PowerShell Commands, we will be finding the Managed Disk State of Unattached, Attached, and Reserved of all the Azure VM Disks within Subscription. Implementation: Follow the below steps to get azure manag
1 min read