Introduction To Document DB In Azure

Introduction

In this article, we will see how to create Azure Document Db which we also know as Azure Cosmos DB.

  • Concept and Prerequisites
  • Implementation – Creating Cosmos DB account of API type Document DB in Azure.
  • Implementation – Creating the Collection in the Document DB
  • Implementation – Querying the document in the collection of Document DB

Concept - About

  • Document DB is a NoSQL database as a service which natively supports JSON and JavaScript directly inside the database engine.
  • You can easily query the data and store the data in JSON format.
  • It is most likely famous DB and anytime available on Azure.

Implementation – Creating Cosmos DB account of API type Document DB in Azure.

  • Sign in to Azure Management portal.
  • Open Azure portal and click on “+”.
  • Type “Azure Cosmos DB” in the search box.

    Document DB In Azure

    Document DB In Azure
  • Then, click on "Create".
  • Fill in all the required details like Id, API, Resource Group, and Location.
  • Give the name of your Document DB as ID and choose API like SQL (Document DB).
  • Then, click on "Create" button.

    Document DB In Azure
  • After this, it creates the Cosmos Document DB.
  • Once it is deployed, start making a collection.
  • Go to Data Explorer and click on "New Collection".

    Document DB In Azure
  • Click on New Collection – Give database Id as the database name and collection id as the table name.
Implementation – Creating the collection in the Document DB.

Document DB In Azure

  • Click OK and your database is ready.
  • Open the collection, click on Documents to see the table structure, and define the columns for your table as database entities.
  • Click on "New Document" as shown below to define the columns in your item table.

    Document DB In Azure

  • Click on the "Save" button.

Implementation – Querying the document in the collection of Document DB.

  • Create new “SQL Query” from the above menu option in the collection.

    Document DB In Azure
  • Now, write the query to get the data where the name is “Viral Jain” and then, execute the query.

    Document DB In Azure

  • You can also connect this database with your application by using URL and keys, as shown in below picture.

    Document DB In Azure

Summary

This is how we can make Document DB a.k.a. Cosmos DB in Azure.