Home » Azure COSMOS Database

Azure COSMOS Database

Azure Cosmos DB is a NoSQL data store. It is different from the traditional relational database where we have a table, and the table will have a fixed number of columns, and each row in the table should adhere to the scheme of the table. In the NoSQL database, you don’t define any schema at all for the table, and each item or row within the table can have different values, or different schema itself.

Advantages of Cosmos DB

Azure COSMOS Database

  • No Schema & Index management: The Azure database engine is fully schema-agnostic. Therefore no schema and index management are required. We also don’t have to worry about application downtime while migrating schemas.
  • Industry-leading comprehensive SLAs: Cosmos DB is the first and only service to offer industry-leading full 99.99% high availability, read and write latency at the 99th percentile, guaranteed throughput, and consistency.
  • The low total cost of Ownership: Since Cosmos DB is a fully managed service, we no longer need to manage and operate complex multi-datacenter deployment, and upgrades of our database software pay for the support, licensing, or operations.
  • Developing application using NoSQL APIs: Cosmos DB implements Cassandra, MongoDB, Gremlin, and Azure Table Storage wire protocol directly on the service.
  • Global distribution: Cosmos DB allows us to add or remove any of the Azure regions to our Cosmos account at any time, with a click of a button.

Cosmos Database Structure

Database: We can create one or more Azure Cosmos database under our account. A database is analogous to a namespace, and it is the unit of management for a set of Azure Cosmos containers.

Azure COSMOS Database

Cosmos Account: the Azure Cosmos account is the basic unit of global distribution and high availability. For globally distributing our data and throughput across multiple Azure regions, we can add or remove Azure regions from our Azure Cosmos at any time.

Container: An Azure Cosmos container is the unit of scalability for both provisioned throughput and storage of items. A container is horizontally partitioned and then replicated across multiple regions.

Global distribution and Partitioning

Cosmos DB works differently from the traditional relational database where we have a table, and all the rows in the table will sit in one physical place. When it comes to Cosmos DB, we will create logical partitions within a container so that we can have a certain amount of items with one partition key and a certain number of items with another partition key. They are called logical partitioning, and each logical partitioning can reside in a physical partition.

Azure COSMOS Database

A container can contain millions of items, and we can divide these millions of items using partition key and make logical partitions, and each logical partition will reside in a physical partition. This is how the load of the container will be distributed across the board locally and also the data from here.

Types of Consistency

Azure COSMOS Database

Azure Cosmos Database approaches the data consistency as a spectrum of choices instead of two extremes. Strong compatibility and eventual consistency are at the ends, but there are many consistency choices along the spectrum.

The consistency levels are region-agnostic. The consistency level of our Azure Cosmos account is guaranteed for all read operations regardless of the region from which the reads and writes are served, the number of areas associated with our Azure Cosmos account, or whether our account is configured with a single or multiple write regions.

Request Units

  • We pay for the throughput we provision, and the storage we consume on an hourly basis with Azure Cosmos DB.
  • The cost of all the database operations is normalized by Azure Cosmos DB and is expressed in terms of Request Units (RUs). The price to read a 1-KB item is 1 Request Unit (1 RU). All other database operations are similarly assigned with a cost in terms of RUs.
  • The number of RU’s consumed will depend on the type of operation, item size, data consistency, query patterns, etc.

Azure COSMOS Database

For the management and planning of capacity, Azure Cosmos DB ensures that the number of RUs for a given database operation over a given dataset is deterministic.

Creating Azure Cosmos DB using Azure portal

Step 1: Click on create a resource and search for Azure Cosmos DB. After that, click on create.

Azure COSMOS Database

Step 2: Fill-in all the details and click on a review to see if any details are missing.

Azure COSMOS Database

Step 3: Configure the network for the Azure Cosmos DB.

Azure COSMOS Database

Step 4: Finally, click on the create button to create your COSMOS database.

Azure COSMOS Database

Step 6: You will see the following window after the successful deployment of Azure Cosmos DB.

Azure COSMOS Database


Next TopicAzure Data Factory

You may also like