Novel Corona Virus spreading all across the globe and Many Countries are requesting their citizen to stay at home for months. While everyone is trying to find some kind of things to do to avoid boredom during a lockdown situation, I decided to do something fascinating with Azure.
It was a Saturday afternoon and I was browsing the internet and checking on the count of covid19 cases now and then. While doing this, I found many websites provide JSON format data of covid19 and they refresh this data every single day. I decided to store this data in my Azure Table / Cosmos DB for my future projects.
To Store the covid19 data, Code has to follow the below 7 Steps workflow:
- Repeat below Steps once every Day as those websites provide the latest data once every day
- Make HTTP Request
- Consume HTTP Response
- Convert HTTP Response to JSON Object
- using a loop, Massage each JSON Document and Convert it into Model class which represent a row/document in Azure Table/Cosmos DB
- Create Connection to Azure Table/Cosmos DB
- Store the Data
As the World is moving towards the "No-Code" trend, I decided to consume this data and store it in Azure Table /Cosmos DB without writing a single line of code.
You must be thinking, How it is possible that without writing a single line of code, one can make HTTP Request to a website endpoint, consume Http Response, convert that Response into JSON, Massaging JSON and finally store in Azure Table / Azure Cosmos DB?
The answer is the Azure Logic App. Yes!!! Azure has a fascinating service called Azure Logic App which can create business workflow without writing a single line of code. With the help of Azure Logic App, One can schedule and automate many business processes. For more details on Azure Logic App, You may visit https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-overview.
Now let me explain How you can use Azure Logic App to store covid19 data in Azure Table/ Cosmos DB.
create a Logic App in the Azure Portal. https://portal.azure.com/
Open Logic Apps Designer page. here You can create a workflow ( 7 steps workflow) with just easy drag and drop.
In the Logic Apps Designer page, We need to collect data once every day and hence We have to select the Recurrence trigger which will be called once every day.
After selecting the Recurrence Trigger, the Next step is to Call Website Endpoint using "HTTP Action". For Data, I am using https://opendata.ecdc.europa.eu/covid19/casedistribution/json/ .
Consume Response of Step 3 and Convert it into JSON using Data Operations --> Parse JSON.
To Parse JSON, it needs a JSON schema. You don't have to manually write it, just provide sample JSON and it will create the schema for you.
As our JSON data contains an array of documents, we need to loop through it, massage it and store it Cosmos.
Massaging Data: Map your response JSON to new JSON document and add "ID" field in the new JSON document
Connect to Cosmos DB, select Database and container ( table). Select Modified JSON Document in Document field, provide partition key-value field.
I hope this post will help you.
Be Safe!! Spread Knowledge, Spread Love but Not Virus
Enjoy Azure & Enjoy Cloud Computing !!!!
Top comments (0)