In this article you will learn the steps to configure Cosmos DB Table API in Azure.
Cosmos DB has five APIs. In this article we will cover table API of Cosmos DB. So let see the steps one by one. Without wasting time, I will directly go with the steps to configure table API.
Go to Azure portal and click on Cosmos DB tile. Here is the URL. https://portal.azure.com/#home
You will land on Cosmos DB resource landing page. Here you can create a new Cosmos DB account of any desired type (We will take table). You will also find existing accounts if any. Click on “+ Add” link to add new account.
Here you need to add resource group first. You can create new resource group from “Create New” link or you can also select existing resource group from dropdown if any.
I have already a trial account, so selected the same. Next step is to add account name and select API type. Here I am showing demo for Azure table so selecting Azure Table.
I have kept rest as untouched like using account type as non-production for demo purpose and rest as default. You can select location as per your requirement. Keep Geo-Redundancy and Multi-region Writes options disabled to avoid additional charges. Skip the Network and Tags sections and click on “Review + Create” to continue.
Request will be validated and if everything is ok, you will see success message. Review the data you have feed and click on Create button to create the account. Deployment will take some time to configure and create account.
Once deployment is completed, click on “Go to resource” button to jump to dashboard.
You will reach to dashboard page where you can find account overview like account details, subscription details with some other details cost, resources etc. Now next step is to create a table. For that, click on “Data Explorer” button or link at left panel.
Click on “New Table” to create a table.
Add table name and select throughput. I have kept default as 400 but you can choose as per the load and cost.
DB is created successfully at this point with name as TableDB having table Person with blank entity as of now. To add entity click on “Add Entity” link.
You will see two default field as PartitionKey and RowKey. Apart from this, you can add custom columns as per requirement from “Add Property” button underneath.
Second time when you try to add entity, you will see column names by default and just require to add values.
PartitionKey and RowKey are unique values and you can use them to maintain uniqueness in your table. Apart from these default columns, you can notice one more column Timestamp that generated automatically. After you added rows in your table, you can view them as below.
To query data, simply select column name from dropdown and enter value to apply filter. You can select more columns using “Add new clause” button. Run query using “Run Query” button.
Hope this helps you