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
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.
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.
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.
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.
Retailer json knowledge in cosmos db and question utilizing sql question
Click on on new merchandise and duplicate paste under json format
- {
- “id”: “2”,
- “identify”: “prasad”,
- “metropolis”: “mumbai”
- } {
- “id”: “1”,
- “identify”: “ganesh”,
- “metropolis”: “mumbai”
- }
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.
- choose * from worker
- [{
- “id”: “replace_with_new_document_id”,
- “name”: “ganesh”,
- “city”: “mumbai”,
- “_rid”: “mUQAAIVYAR4BAAAAAAAAAA==”,
- “_self”: “dbs/mUQAAA==/colls/mUQAAIVYAR4=/docs/mUQAAIVYAR4BAAAAAAAAAA==/”,
- “_etag”: “”17009a5a-0000-0700-0000-5f92fa2e0000″”,
- “_attachments”: “attachments/”,
- “_ts”: 1603467822
- }, {
- “id”: “2”,
- “name”: “prasad”,
- “city”: “mumbai”,
- “_rid”: “mUQAAIVYAR4CAAAAAAAAAA==”,
- “_self”: “dbs/mUQAAA==/colls/mUQAAIVYAR4=/docs/mUQAAIVYAR4CAAAAAAAAAA==/”,
- “_etag”: “”17008069-0000-0700-0000-5f92faed0000″”,
- “_attachments”: “attachments/”,
- “_ts”: 1603468013
- }]
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!