Creating Azure Cosmos DB Using Azure Portal

In this article, we will learn how to create the Azure Cosmos DB using the Azure Portal. So let's start creating the Cosmos DB service step by step.

Prerequisites

You need a valid Azure subscription either free or paid to create any service in the Azure, I hope you have a valid subscription.

What is Azure Cosmos DB?

Azure Cosmos DB is the NoSQL database which is a globally distributed and highly available database. The Azure Cosmos DB stored the data in the JSON format. The database is easily scalable by a few clicks across the regions.

Step 1: Login To Azure Portal

Navigate to the portal.azure.com using a browser and login into the portal with valid credentials, as shown in the following image.

After a successful authentication, the page will be redirected to the Azure portal default dashboard page as shown in the following image.

 Step 2:  Create the Azure Cosmos DB

Find the create resource option which can be found left top side of the portal as shown into the following image or follow any other option which you may know to create the resource (service) in the Azure portal. Search for the Azure Cosmos DB as shown in the following image.


As shown in the preceding image, click on the create button, it will show the following screen.


Provide the required details as shown in the preceding image

Subscription

Choose the available Azure subscription which you want to use for creating the service from the drop down list.

Resource Group

Choose an existing resource group or create a new resource group which you may want to use.

Account Name

Provide the unique name for the Azure Cosmos database account which creates the universal unique URI by appending the Cosmos database service URL.

API

Azure Cosmos database provides the five API's which decide what type of data is stored into the cosmos DB. The following are the API's.

  • SQL API
  • Cassandra API
  • Gremlin API
  • Table API
  • MongoDB API
In our article we are using the SQL API.

Location

Choose the deployment location for Azure Cosmos database from the given list.

Capacity Mode

The capacity mode decides the processing capacity for your database which are as

  • Provisioned throughput 
  • Serverless

The database operation cost also differs depending on the selected capacity mode.

Apply Free Tier Discount

You can decide whether to apply or not to apply the free tier discount. If you apply the free tier discount, you will get the first 400 RU/s and 5 GB of storage for free in an account.

Account Type

The Azure Cosmos database allows users to choose the following two account types.

  • Production
  • Non-production

If your application is running in the production environment, then choose the Production account type; otherwise, choose the non-production account type. This is only the azure resource tag which does not impact on any cost-related things on your Cosmos database account.

Geo-redundancy

You can enable the disable of your account global distribution by pairing with the other region. This makes sure that your database account will be globally replicated along with another region.

Multi-region Writes

The Azure Cosmos DB is capable of writing the data on the multiple regions. If you want to write the data to multiple regions, then just enable the button, otherwise keep it in disable mode.

After providing all the required basic details, click on the next button, then the networking screen will get appeared where you can define the networking details as shown in the following image.


As shown in the preceding image, you can decide from which network the Azure Cosmos database is available to connect that is either public network or private network or both the networks.

Now after providing the required networking details, click on the next Backup policy option, then the following screen will appear where you can define the Backup policy details.


You can choose the backup policy, how frequently database backup can be taken by using the periodic or Continuous option, as shown in the preceding image.

Now after providing the required backup policy details, click on the Next Encryption button, then the following screen will appear where you can define the encryption details.


As shown in the preceding image, choose how data is encrypted that is either using the service managed key or customer managed key.

Once you choose the data encryption method, click on the next step tags, which will show the following screen.


The tagging helps to identify or categorize the services across the line of applications. After providing the tag details, click on the next step, Review and Create, then the following screen will get appeared to review the details before creating the service.


After reviewing details, click the create button, it will take some time to create the service. Once the service is created, the status can be notified on the notification icon. Now click on the Go to resource button, you will be redirected to the newly created Azure Cosmos database service.

The Azure Cosmos database welcome screen will look like as shown in the following image from which you can manage your Azure cosmos database.


Step 3: Create the DataBase and Container.

In previous steps we have created the Azure Cosmos database account. Now we need to create the database and a container to store the data. Use the data explorer option as shown in the following image.


As shown in the preceding image, HumanResource is the database id and EmployeeMaster is the Container Id. These two terms are equivalent to the database name and table name respectively in a relational database.

The Database throughput decides the request-proceesing capacity for your database which you can choose between the Manual and Autoscale. Choose the manual for this article and keep 400 RU/s (request units per second), which is the default. We have chosen Partition Key as departmentName which can logically distribute the data on the multiple servers which makes database operation faster, each partition key has 20 GB of capacity.

I hope you have provided the required details as explained in the preceding, now click the Ok button, then it will create the database and container as shown in the following image.


Step 4: Adding the New Item

Now we have a Database and Container Id, let's add the item (records) into it as steps shown in the following image.


Now use the preceding document structure and click on the save button. After saving the document, it will look like as follows.


As you can see in the preceding image, what the added document structure looks like, Cosmos DB will add some auto-generated properties which can be mostly useful during the database operation.

Summary

I hope from the preceding explanation you have learned how to create the cosmos database and add the document.

Related Articles

Post a Comment

www.CodeNirvana.in

Protected by Copyscape Online Copyright Protection
Copyright © Compilemode