Azure

Azure Cosmos DB – Retailer And Retrieve JSON Knowledge Varieties Utilizing SQL API

Introduction

 

On this article we’ll attempt to perceive Azure Cosmos db service, and likewise create our first Cosmos db account to retailer and retrieve Json knowledge utilizing SQL API.  We may even attempt to perceive the advantges of utilizing cosmos db. 

 

Conditions 

  • Microsoft free account and Azure Credit.
  • Fundamental data of utilizing Azure Companies

On this article, we’ll cowl the next matters:

  • Benefits of utilizing Azure cosmos db
  • Step-by-step creating and configuring cosmos db SQL API knowledge retailer 
  • Retailer json knowledge in cosmos db and question utilizing sql question.

Benefits of utilizing Azure cosmos db

  • Cosmos db is totally managed;  no SQL knowledge retailer 
  • Haven’t got to fret about underlying infrastructure 
  • Routinely scales storage
  • Routinely scales compute
  • Help many APIs inculding SQL,Mongo db,Cassendra,Desk and Gremin. 

Doc database terminolgies

 

On this article we shall be storing json knowledge and utilizing SQL API for a similar.

 

Container in SQL API will symbolize desk in our RDMS 

 

Doc IN SQL API will symbolize a desk row from RDBS

 

Step-by-step create and configure cosmos db SQL API knowledge retailer

 

Azure Cosmos DB - Store And Retrieve JSON Data Types Using SQL API

 

Choose your Azure subscription and  choose your useful resource group.

 

Add distinctive account identify and and choose API Kind.

 

On this article we’ll choose SQL API (we shall be storing jason sort knowledge).

 

One Azure cosmos db account is simply used to retailer sure forms of knowledge.

 

Azure Cosmos DB - Store And Retrieve JSON Data Types Using SQL API

 

Choose apply free tier low cost.It will give us 400 Ru/s(Request models) and 5 GB of storage.

 

We’re charged for Azure cosmos db primarily based on Ru/s and underlying storage.

 

Preserve the identical remaining settings.

 

Click on on evaluation and create.

 

It’ll take 5-10 minutes to spin up new useful resource.

 

Provisional Throughput

 

In Azure cosmos db you might be charged for the throughput you provision and this stoarge is consumed on an hourly foundation.

 

Relying on the quantity of throughput you provison the correct amount of CPU reminiscence and IOPS shall be assigned.

 

You’ll be able to assign throughput at container degree or database degree.

 

The price to learn 1 kb merchandise is 1RU 

 

The opposite database opertions take their very own quantity of throughput relying on database operations.

 

Azure Cosmos DB - Store And Retrieve JSON Data Types Using SQL API

 

Click on on create container and specify identify.

 

This shall be our database identify. 

 

Throughput begins from 400.

 

We might additionally see estimated spend.

 

We’re mentioning 400 RU for our database.

 

Azure Cosmos DB - Store And Retrieve JSON Data Types Using SQL API

 

Specify container id.

 

This would be the identify of our database desk.

 

Specify parition key. 

 

Knowledge shall be spent throughout a number of partions primarily based on partion key.

 

Click on on okay our desk has now been created.

 

Azure Cosmos DB - Store And Retrieve JSON Data Types Using SQL API

 

Retailer json knowledge in cosmos db and question utilizing sql question 

 

Click on on new merchandise and duplicate paste under json format

  1. {  
  2.     “id”“2”,  
  3.     “identify”“prasad”,  
  4.     “metropolis”“mumbai”  
  5. } {  
  6.     “id”“1”,  
  7.     “identify”“ganesh”,  
  8.     “metropolis”“mumbai”  
  9. }  

Click on on save we might see 2 gadgets have been added to database.

 

Navigate by way of new SQL question and execute the under question.

  1. choose * from worker   
  1. [{  
  2.     “id”“replace_with_new_document_id”,  
  3.     “name”“ganesh”,  
  4.     “city”“mumbai”,  
  5.     “_rid”“mUQAAIVYAR4BAAAAAAAAAA==”,  
  6.     “_self”“dbs/mUQAAA==/colls/mUQAAIVYAR4=/docs/mUQAAIVYAR4BAAAAAAAAAA==/”,  
  7.     “_etag”“”17009a5a-0000-0700-0000-5f92fa2e0000″”,  
  8.     “_attachments”“attachments/”,  
  9.     “_ts”: 1603467822  
  10. }, {  
  11.     “id”“2”,  
  12.     “name”“prasad”,  
  13.     “city”“mumbai”,  
  14.     “_rid”“mUQAAIVYAR4CAAAAAAAAAA==”,  
  15.     “_self”“dbs/mUQAAA==/colls/mUQAAIVYAR4=/docs/mUQAAIVYAR4CAAAAAAAAAA==/”,  
  16.     “_etag”“”17008069-0000-0700-0000-5f92faed0000″”,  
  17.     “_attachments”“attachments/”,  
  18.     “_ts”: 1603468013  
  19. }]  

Thus we have now succesfully saved and retrieved json knowledge from azure cosmos db utilizing SQL ApI.

 

Including extra gadgets.

 

By copying the above json format we will carry on including extra gadgets to our Worker desk.

 

On the proper hand facet prime there may be choice to open Azure cosmos db operations window in full display screen.

 

We will click on on proper hand prime and click on on open.

 

It will open full display screen in new window.

 

Abstract

 

On this article, we have now realized learn how to create, configure, and deploy our first Azure cosmos db account.

 

We’ve seen a number of the benefits of utilizing Azure cosmos db service.

 

We’ve additionally seen learn how to add new gadgets in our desk and question utilizing SQL question.

 

Thus we have now retailer and retrieved json knowledge utilizing SQL API.

 

Thanks quite a bit for studying. I hope you favored this text. Please share your invaluable solutions and suggestions. Write within the remark field in case you have got any questions. Have a very good day!

Tags
Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Close