Kick Start with Azure Cosmos DB

by Santhakumar Munuswamy

  Posted on  28 February 2018

  Azure Cosmos DB


 In this article, we will discuss Azure Cosmos DB, What is a Cosmos DB? Why do we need to use the Cosmos DB? We will learn How to create a new Azure Cosmos DB account using Azure subscriptions, How to create a new database and collection using Azure, How to add data to the collection using Data and etc.


In this article, we will see the following,
  • What is Azure Cosmos DB?
  • Why do we need to use the Cosmos DB?
  • How to create a new Azure Cosmos DB account using Azure 
  • How to create a new database and collection using Azure
  • How to add data to the collection using Data Explorer 
  • How to use SQL Query to the collection using Data Explorer
  • How to get Cosmos DB connection string from Azure 

Prerequisite

  • Azure Subscriptions

What is Azure Cosmos DB?

Azure Cosmos DB is a globally distributed database services. It supports multi-model approaches such as the document, Key/Value, wide columns and graph databases using APIs. 

The list of APIs as the following 

  • SQL API
  • MongoDB API
  • Graph API
  • Table API
  • Cassandra API


Why do we need to use the Cosmos DB?

Azure Cosmos DB is offering the following items

  • Global distributions
  • Elastic scale out
  • Guaranteed low latency
  • Five consistency models
  • Comprehensive SLAs

How to create a new Azure Cosmos DB account using Azure 

You can learn in this section, how to create a new azure cosmos database account creation using the Azure portal at the following guidelines.

Go to open the new browser, you can copy and paste the following URL


Then, Sign in the Azure portal using Microsoft Account credential



After successfully logged into the Azure portal. You can see the dashboard looks at the following screenshot



You can go to create a resource à Databases à click the Azure Cosmos DB



The Azure Cosmos DB new account window will be opened and you can enter the following details are required for the screenshots. Then, click the Create button.

  • ID
  • API 
  • Subscription Name
  • Resource Group Name
  • Location
The list of API Option is available in the following screenshot




Now, you can see the notification window displaying the deployment in progress notification. Once it is completed you will get the deployment succeeded notification in the notification window. Then, click Go to resource button.





After successfully Azure Cosmos DB account is created, the Congratulations! Your Azure Cosmos DB account was created window will be opened in the following screenshot.



How to create a new database and collection using Azure

You can learn in this section, how to create a new database and collection in Data Explorer using Azure portal at the following guidelines.

You can go to Data Explorer à click the New Collections



The Add Collection window will be opened and you can enter the following details are required for the screenshots. Then, click the OK button.

  • Database Id
  • Collection Id
  • Storage Capacity 
  • Throughput




You can see the new database and collection looks at the following screenshot.



How to add data to the collection using Data Explorer

You can learn in this section, how to add sample data to the collection in Data Explorer using Azure portal at the following guidelines.

You can go to Data Explorer à Expand the Table collection in the Collection window, click the Documents à click the New Document.



The new document window will be opened and add the data to the collection with the following format.



JSON

{

      “Id”: “1”,

      “TableName”: “Table A”,

      “Location”: “Front Row”,

      “Status”: “Available”,

      “Date”: “28-02-2018”

}


Once you have added JSON data to the document and click the Save button.




After successfully added records to the collection looks like the following screenshot




How to use SQL Query to the collection using Data Explorer

You can learn in this section, how to use SQL query to the collection in Data Explorer using Azure portal at the following guidelines.

You can go to Data Explorer à Expand the Table collection in the Collection window, click the New SQL Query



The Query window will be opened as below screenshot



Once you have executed query by clicking Execute Query button


 


you can use Where condition and Order By for the select statement on SQL Query window in the Azure Cosmos DB as below screenshots






How to get Cosmos DB connection string from Azure

You can learn in this section, how to get the Cosmos DB connection string in Keys using the Azure portal at the following guidelines.

You can go to Settings à click the Keys

 


Now you can copy the URI and Primary Key into your web.config file in your project.


Reference


Conclusion

I hope you understand now about Azure Cosmos DB, How to create a new Azure Cosmos DB account using AzureHow to create a new database and collection using Azure, How to add data to the collection using Data Explorer, How to use SQL Query to the collection using Data Explorer and How to get Cosmos DB connection string from Azure. I have covered all the required things. If you find anything missing, please let me know. 

Please share your valuable comments or feedback to improve my future articles.

 


About the Author
Santhakumar Munuswamy is a seasoned Solution Architect and Most Valuable Professional in Cloud /AI solutions. He has been experienced around 14 years in Solution designing, Software Product Development, Technical Documentation, Project Management for Web and Cloud Applications. He has experience in the IT industry across different domains (Automotive, Telecommunications, Healthcare, Logistics & Warehouse Automation, etc.) with roles in Technical Architect, Genesys Consultant, Technical Lead, Team Lead, and Developer. He has experienced in mentorship and coaching high potential developers.

Follow Me: Facebook, Twitter, Google Plus, LinkedIn
blog comments powered by Disqus


Month List

Community Badges