In this article we can explore about Cosmos Db database & its usage.
Azure Cosmos DB is a globally distributed, multi-model, planet-scale, low-latency, high-availability, No-SQL database stored as JSON format.
In the olden days Cosmos DB was called as Azure DocumentDB.
Azure Cosmos DB will be replicated based on Geography region & hence low-latency. There will be Primary Write-database in one central location & Multiple Secondary Read-databases in multiple locations.
Due to the multiple geographical location availability low-latency & high-availability is possible.
Cosmos DB supports Multiple-API support:
· SQL API
· Mongo API
· Graph API
· Table API
· Cassandra API
JSON Format is used to store the data in Cosmos DB.
Cosmos DB have 5 consistency levels to ensure consistency, availability and latency trade-offs.
Create Cosmos DB
We can create Cosmos DB from Azure Portal as shown below.
Open Azure Portal > Create new resource > Cosmos DB
Click the Ok button & Wait for few minutes for the Creation to be completed.
You will get the following screen after creation.
Start by Add Collection. Then Add a New Document.
You can add new properties in the document. The data is stored as JSON file. Ensure the ID is unique.
Now we can query the database using SQL. Choose the New SQL Query option > Enter SELECT statement & Execute the Query. You will get the following results as displayed.
In this article we have explored about Cosmos Db database & its usage.