How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In today’s blog post, we will discuss how to connect to Azure Cosmos DB using Azure Cosmos DB Explorer. We will first create an Azure Cosmos DB account using Azure Portal and then will connect to the Azure Cosmos DB account in Azure Cosmos DB explorer. Once connected, we will also create a new database, container and perform CURD operation in our Azure Cosmos DB using Azure Cosmos DB Explorer.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Step 1: Create a resource group for Azure Cosmos DB.

Log in to Azure Portal.

https://portal.azure.com/

Navigate to “Resource Groups”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Click on “Create” to create a new resource group.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Select your subscription and region and provide a name for the new resource group. Finally, click “Create” to create the new resource group.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Step 2: Create an Azure Cosmos DB account.

Navigate to Azure Cosmos DB service.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Click “Create Azure Cosmos DB Account”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Select the API type for your Azure Cosmos DB. For this demo, we will use SQL core API.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Provide a name (must be unique globally) and other details and click “Next: Global Distribution”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Select the distribution level for your Azure Cosmos DB and click “Next: Networking”. To reduce cost, we will not enable global distribution for our Azure Cosmos DB.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Next, select the networking mode for your Azure Cosmos DB and click “Next: Backup Policy”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Select the backup options for your Azure Cosmos DB and click “Next” Encryption”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Select the encryption option for your Azure Cosmos DB and click “Next: Tags”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Optionally, you can tag your Azure Cosmos DB account, Click “Review + Create” to review and create your Azure Cosmos DB account.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Step 3: Connect to Azure Cosmos DB Account With Azure Cosmos DB Data Explorer.

Navigate to Azure Cosmos DB Account > Keys and copy the “Primary Connection String”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Now open https://cosmos.azure.com/ in another tab of your browser.

Click on “Connect to your account with connection string.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Provide the connection string copied earlier and click “Connect”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

We have successfully connected to our Azure Cosmos DB account in Azure Cosmos DB Explorer.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Now we can use this Azure Cosmos DB Explorer to create new databases, containers and perform CURD operation on our Azure Cosmos database.

Step 4: Create a new database in Azure Cosmos DB using Azure Cosmos DB Explorer.

In Azure Cosmos DB Explorer, click “New Database”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Provide Database Name (ID) and throughput and click “Create”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Next, we are going to create an Azure Cosmos DB container inside this database.

Step 5: Create an Azure Cosmos DB container using Azure Cosmos DB Explorer.

In the Azure Cosmos DB Explorer, click “New Container”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Select the database created in the previous step, provide a name (ID) and partition key for the container and click “OK”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

We have successfully created the Azure Cosmos DB container and database using Azure Cosmos DB Explorer.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Step 6: Insert data into Azure Cosmos DB using Azure Cosmos DB Explorer.

Inside your container click on “items” and then click on “New item”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Add the below data in the query window and click “Save”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Similarly, add a second item with the below data.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

We have successfully inserted data into our Azure Cosmos DB. Next, we are going to update data in Azure Cosmos DB.

Step 7: Update data in Azure Cosmos DB using Azure Cosmos DB Explorer.

Select the item that you want to update and update the value in the query editor. Once updated, click “Update” to update the item in Azure Cosmos DB using Azure Cosmos DB Explorer.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Note: We have updated the “manufacturer” value from “Conteso” to “Cloudaffaire” in this demo.

Step 8: Delete data in Azure Cosmos DB using Azure Cosmos DB Explorer.

To delete an item in Azure Cosmos DB, select the item you want to delete and click on “Delete”.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Confirm the deletion of the item by clicking on the “Delete” button.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Step 9: Clean up.

In the Azure Portal, get inside the resource group that you have created at the very first step of this demo. Click on “Delete resource group” to delete all the resources in your resource group.

How to connect to Azure Cosmos DB using Azure Cosmos DB Explorer?

Hope you have enjoyed this article. To get more details in Azure Cosmos DB, please refer to the below documentation.

https://docs.microsoft.com/en-us/azure/cosmos-db/

Leave a Reply

Close Menu