Setting up Azure Cosmos DB

 Ok, let's take it one by one. Let's start with setting up of a cosmos DB cluster. But before that lets discuss some general info about cosmos db. 

What is cosmos DB?

If you search Wikipedia, you will get following result.

Azure Cosmos DB is Microsoft's proprietary globally distributed, multi-model database service "for managing data at planet-scale" launched in May 2017.[1] It is schema-agnostic, horizontally scalable, and generally classified as a NoSQL database.

So, I can understand that it's a Microsoft provided NoSQL datastore which provides different properties as mentioned in its description. I am not going into the details of these properties in this article as it's beyond the scope of it. I would only discuss about how to set it up.

Now, let's jump on to the setup of cosmos DB.

How to setup cosmos DB? 

In order to do it, you need an azure account. In order to create a free one, you can use: Create Your Azure Free Account Today | Microsoft Azure you would get 200 dollars of free credits.

  1. Once you have the account, you would see something like this, click on select Create a resource.          
  2. Then, you would see this screen mentioned below, Select Azure cosmos DB.
  3. Next screen is going to ask you to select API option, select the Create option within the Core (SQL) - Recommend section. Azure Cosmos DB provides five APIs: Core (SQL) and MongoDB for document data, Gremlin for graph data, Azure Table, and Cassandra. Currently, you must create a separate account for each API. Learn more about the SQL API.
  4. Fill in the details according to your needs in the Basics section, here is my update but feel free to fill it according to your needs.

  5. In the global distribution section, select policy according to your needs I am going with default one

  6. Optionally, you can add more details in the following tabs, Network latency, Backup Policy, Encryption, Tags.


  7. Click review and create...
  8. Review all the settings and then click on create, wait for the instance to be up it may take up time up to few minutes.
  9. Once instance is created, click on go to resource to go to azure cosmos dB accounts page.
    Now Let's create a database and container to it. 

Database seems clear but what is container?

An Azure Cosmos DB container is a schema-agnostic container of arbitrary user-generated entities and stored procedures, triggers and user-defined-functions (UDFs). 

Now, let's talk about container creation:
  1. For creating container go to Data explorer section, select new container, then a window would pop up on the right side

  2. Select ok, a new DB instance can be seen under data explorer.
Let's add some data to our database:
  1. Click on the items under database and then click on new item tab.
  2. Add following Json:

  3. click on save and a new entry would be created with some extra fields

     
References:
  1. Wikipedia
  2. Microsoft cosmos DB docs.








Comments

Popular posts from this blog

Kustov query language

Making all service APi's generic

How I learned LINQ query Fundamentals