Quick Start With Azure Cosmos DB - Day Two

In my previous article, we have seen the structure of Cosmos DB, signed up azure free account for 30 days and created Cosmos DB account using Azure Portal.. today, we will see how we can create document under COSMOS DB through azure portal using 'Quick Start' link.

Introduction

In my previous article, we have seen the structure of Cosmos DB, signed up on Azure free account for 30 days, and created Cosmos DB account using Azure Portal. Today, we will see how we can create a document under Cosmos DB through the Azure portal using 'Quick Start' link. You can read the previous article from here.

Azure portal provides the facility to create a document under Cosmos DB for beginners who are not aware of its usage. As per the structure of Cosmos DB, the next step would be creating database and collection. So, let's click on 'Create Items Collection' button; it will create a database and a collection.

Cosmos DB

Select your preferred platform and click on 'Download' button to download the application. You can download in .NET, .NET Core, Xamarin, java, Node.js, and Python. Here, I have downloaded the same in .NET platform.

Cosmos DB

Extract the downloaded application and double click on todo.sln file to open the solution in Visual Studio.

Cosmos DB

Cosmos DB
As of now, there is no need to understand the code. Just run the solution.

Cosmos DB

It shows a list of existing documents as well as the link to create a new document, so click on 'Create New' link.

Cosmos DB

Fill in the rendered form in order to generate a document, which has three properties - Name, Description and Completed. Press the 'Create' button and the document will be created under Cosmos DB.

Cosmos DB

Now, let's verify in the Azure portal, whether the document is created or not. Click on 'Data Explorer', Expand 'ToDoList' database, and it shows Items collection. Expand 'Items' collection and click on 'Documents'. You can see a list of documents with id having GUID. Click on id and it will show the document in JSON format. You can find the same details which you have added in the preceding form.

Cosmos DB

How is this application connected with Cosmos DB?

In order to connect Cosmos DB, we need endpoint, authkey, database, and collection. We are aware of the database and collection but need to get endpoint and the authkey.

Cosmos DB

Click on Azure Cosmos DB under the services, select account, and explore Keys, where we can find the URI, i.e., endpoint and primary key (the authkey).

Cosmos DB

In the next article, we will create Cosmos DB and collection using the portal, as well as through .NET.

<< Previous Part