Wednesday, January 15, 2020

Data Platform Tips 49 - Creating a container on Azure Cosmos DB

In this post we will look at how to create a container, add items and query items from the container on Azure Cosmos DB.




a) Log on to the Azure Portal.

b) Open the provisioned Cosmos DB and click on "Add Container".















b) Cosmos DB Data Explorer will be opened and new Container window will be available for you to provide the details.













c) Provide the details as shown below and click "Ok"

























d) Once the container is created, you can see the container details below.












e) Now, let us create an item within the container by clicking new item and provide the below json and click on save.

{
  "id": "1",
  "type": "user",
  "userId": "TestUser1",
  "username": "Test User1"
}











f) Once saved, Cosmos DB creates additional attributes as highlighted below.










g) To query the container, click the "..." beside the container name and click on "New SQL Query"





















h) Once clicked on "New SQL Query" a SQL Query window will be opened with the pre-defined select statement as shown below and click on Execute Query to see the results.

















No comments:

Post a Comment