Azure Cosmos DB

Azure Cosmos DB

Azure Cosmos DB

Azure Cosmos DB is NoSQL database. Cosmos DB includes database, containers and items exposed by numerous APIs. When choosing a data Store for an application, if the following scenarios match the data storage requirements, then Azure Cosmos DB would be an optimal decision:

  • Utilizes Key/value pairs
  • Needs documents storage capability
  • Graphs data stores
  • Globally replicates data
  • Provides results in JSON format
  • Exposes data using a RESTFul API

When Cosmos DB is provisioned from Azure, one required attribute to select is the API, which also dictates which database type to implement. Below are some supported Cosmos DB types:

  • Core (SQL)
  • MongoDB
  • Cassandra
  • Azure table
  • Gremlin (Graph)

Let’s move and understand other Azure Cosmos DB Concepts, such as following:

  • Azure Cosmos DB API Models
  • Databases, Containers, Items and Partition keys
  • py code
  • Azure Cosmos DB migration option
  • Querying an Azure Cosmos DB
  • Global Replication Concepts

Let’s discuss One by one.

Azure Cosmos DB API Models

Below are list of Azure Cosmos DB APIs and data models.

One of the benefits of Azure Cosmos DB API is that , when you scale out to multiple instances , your application continues to be bound to single instance of your data.

Databases, Containers

An Azure Cosmos DB core (SQL) database is similar in purpose to an Azure SQL database in that it acts as a grouping of the actual data stores that contain data. One caveat is that all databases within the Azure Cosmos DB account must be for the same API. Azure Cosmos DB APIs list is already discussed in above table. You cannot have a Core (SQL) database and an Azure Table in the same Azure Cosmos DB account. This makes sense and has the same behavior as exists when compared to Azure SQL. In the Azure SQL case, there is only one kind of database, SQL Server. Therefore, you can have only that one kind of database within the Azure SQL database grouping.

From Architecture point of view, the container is important because , it is the location where scaling occurs and the SLA is applied. A Container is place where you add things such as stored procedures, user Defined Function (UDF) and triggers.

From an Azure Cosmos DB perspective, you would likely consider the data that is stored in the container and database as the most important. The data is stored as Items, and by clicking Items after accessing the database and container on the Data Explorer blade, it executes a SELECT * FROM c and lists the ID and the partition key. The item can be represented in numerous forms depending on the selected API. In this case, where Core (SQL) is used, the item is considered a document, which is appropriate as we stored a JSON document in it and refer to this as a document database.

Cosmos.Py code: is python code, which imports azure. Cosmos library. After importing, it than imports the JSON document that will be stored in database once it has been created.

The code then creates a client using the endpoint and key; creates the database, the container, and the partition key; and adds two items.


    You are will be the first.


Please login here to comment.