Article Overview
Background
Azure Cosmos DB
Azure Cosmos DB Items
Create Azure Cosmos DB account
Add Database and Container
Add Data in Database
Clean up resources
Summary
This article describes a complete process of how to manage various tasks on an Azure Cosmos DB account through Azure portal. Azure Cosmos DB can also be managed by using Azure CLI, Azure PowerShell, Azure Resource Manager templates, Bicep, or Terraform. This article describes following activities one by one by using Azure Portal:
1. Background
1.1. Azure Cosmos DB
It is fully managed and globally distributed NoSQL database service. It is specially designed for applications which requires high availability and low latency. It also provides elastic scalability across the multiple regions. It supports following four data models:
Document (JSON) – MongoDB API
Key-Value (Item) – Table API
Column-Family (Row) – Cassandra API
Graph (Node or edge) – Gremlin API
Following figure shows hierarchical representation of Azure Cosmos DB account entities.
![Azure Cosmos DB account entities]()
1.2. Azure Cosmos DB Items
Below table shows the supported Azure Cosmos DB entities and items.
| No | Azure Cosmos DB entity | Azure Cosmos DB item |
|---|
| 1 | NoSQL API | Item |
| 2 | Cassandra API | Row |
| 3 | MongoDB API | Document |
| 4 | Gremlin API | Node or edge |
| 5 | Table API | Item |
2 Create Azure Cosmos DB account
Let’s create and manage Azure Cosmos DB account using Azure Portal. Azure Cosmos DB can also be managed by using Azure CLI, Azure PowerShell, Azure Resource Manager templates, Bicep, or Terraform. Perform following steps one by one in to Azure Portal to achieve this.
Sign in to Azure portal.
Azure Cosmos DB search in global search bar.
![Azure Cosmos DB search]()
Create Azure Cosmos DB for NoSQL from Azure Cosmos DB panel using Create button.
![Create Azure Cosmos DB for NoSQL]()
Select API best suits i.e. Azure Cosmos DB for NoSQL option.
![API best suits]()
Basic panel configuration - Now it’s time to enter the basic settings for Azure Cosmos DB account created. For unspecified options leave to their default values as it is. Following are important setting to be configured:
![Basic panel configuration]()
Subscription: appropriate subscription selection.
Resource Group: Create new group such as “ex01-cosmos-db”.
Account Name: unique name is required to identify Azure Cosmos db account. Name can have only lowercase letters, numbers, and the hyphen (-) character. Length must be between 3-31 characters.
Availability Zones: Choose Disable.
Location: Use appropriate location which is nearest to users for fastest data access.
Capacity mode: Choose Serverless.
Review + Create panel - it allows to review and validate the settings which are being configured and complete final save by clicking on Create button.
![Review Create panel]()
Deployment is complete panel - Wait for a while to complete the deployment process to load Deployment complete panel. Click on “Go to resource” button to navigate in Azure Cosmos DB account page.
![Deployment complete panel]()
Now, new created Azure Cosmos DB account is ready to use for next process.
3 Add Database and Container
Once an Azure Cosmos DB account is ready next step is to create a database and a container. Perform following steps one by one in to Azure Portal to achieve this.
Data Explorer selection from left navigation bar in Azure Cosmos DB account page and then click on New Container option.
![Data Explorer selection]()
New container pane configuration - configure the following basic settings for the container:
![New container pane configuration]()
Database id: Create new,with name ToDoList.
Container id: Enter Items.
Partition key: Enter /category.
OK selection - Click on Ok button to save the configuration and to create database and container. Data Explorer panel will display database and container recently created.
Now, database and container is ready for next process to data add and retrieve.
4 Add Data in Database
Let’s use Data Explorer to add data into created database. Perform following steps one by one in to Azure Portal to achieve this.
In Data Explorer, expand to ToDoList database and than expand to Items container. Now select Items, and than click on New Item button to add data in database.
![Add Data in Database]()
Items pane will be open and add the following structure to the item and then click on Save.
JSON
{
"id": "1",
"category": "computer",
"name": "desktop",
"description": "HP All-in-One Desktop PC",
"isComplete": false
}
Now, it’s done as data is added in database.
5. Clean up resources
Once finished the exercise it’s recommended to delete cloud resources are being created to avoid the unnecessary resource usage and any future costs. Deleting a resource group will delete all resources contained within it. Perform following steps one by one in to Azure Portal to achieve this.
Overview selection from left side navigation on the Azure Cosmos DB account page.
Resource group selection for ex01-cosmos-db in Essentials group.
Delete resource group selection and then follow next directions to delete resource group and all the resources it contains.
6. Summary
Here, a complete process flow is described to manage various tasks on an Azure Cosmos DB account by using the Azure portal. First a Azure Cosmos DB account is created. After that added a database and a container. Later on data is added to the database. At the end resources are being cleaned up.