Understand Azure Cosmos DB - Table API

Cosmos DB is a globally distributed multi-model database. Using the API, applications running on Azure Table storage can take advantage of secondary indexes, turn-key global distribution, dedicated throughput, and single digit millisecond latency with 99.99% comprehensive SLAs.

If you are new to this concept, please read more in my article Key Capabilities Of Azure Cosmos DB.

We are talking about Azure Cosmos DB specifically in Table API means table apps with cosmos. The key value databases were among the first studio databases. There are two benefits of accessing patterns using primary key.

  • Builds an application with good design pattern: They are built for scale.
  • Making at assumption: you can push some of the heavy-lifting about scale out of your database. So, you don’t have to ever worry about your data growing or your request slowing down as your data grows. All of that is handled behind the scenes for you.

If you look at Azure Table Storage, this is one of the best production grade, fast, and highly scalable key value database in the market.

Now, Table Storage has gone a little bit further. The value itself a key value pair, so you get the nice table like API abstraction.  You work with this table API that you are familiar with. Now, you just not only have primary key access but also have database queries like in your relational databases.

And the key has also become a little bit more powerful. It has two parts -  partition key and enroll key so it’s useful for applications.

Mainly two feedbacks come from customers,

  • Need an index or Secondary Index, so the query runs faster.
  • Ask for premier -- premier features are dedicated throughput, and have single digit millisecond latency with 99.99%

So, the Azure CosmosDB is one of the great options to combine with these two features. In this table API, we use a secondary index and also premium features like Latency with 5 or 6 digits of 9’s with more accuracy.

So, now, let's started with going on the Azure Portal. I am going to show how to create Azure Cosmos DB with Table API.

Click “New”, then select “Databases”, and then click on “Azure CosmosDB”.  
Fill in all the entries like id, API (That is the important part. Here, we are going to use Key-Value) , subscription, resource group, location, and then click “Create”.

Azure Cosmos DB

Then, go to Cosmos DB account and click “Quick Start". Then, click “Create Table". From “Quick Start", you can download the .NET app; it's a nice quick start with inbuilt connection string.

Azure Cosmos DB 

Once the table is created, go to the “Database Explorer” >> Entities, and click on “Add Entity”.

Azure Cosmos DB

Fill in all the entity entries and then click “Add Entity”. Every property must have partition key and row key.

Azure Cosmos DB

I am adding one more Entity. The fun part is that I can change schema so I am adding a new column "State".

Azure Cosmos DB

To build queries with Cosmos DB, click on "Add new clause".

Azure Cosmos DB

Once you run it, it will filter the record based on your clause.  Azure portal has very good Quick Start --  you can Clone the sample application in Visual Studio. I will talk more about this using Visual Studio in my upcoming articles.

Change "Scale and Settings" of Azure Cosmos DB. You can change the throughput in case of requests per second, or if you want to give only primer key based access. You can simply do it from here.

Azure Cosmos DB

The best part to speed up your app performance using Cosmos DB is that you can set up global distribution also. Here is the example of three regions. You can use as many as you want. It helps your performance to boost your network.

Azure Cosmos DB

When we talk about global distribution from East to West, it only takes 10 milliseconds. This makes the system faster. If an error occurs or any failover is there, you can stop your application in a singlr click on a button. This is very easy, the recovery of failover systems. It has also longer consistency level to improve system compatibility.

Love this article? Do not forgot to share and leave comment below. Happy Programming!!