DEV Community

msmittalas
msmittalas

Posted on

AZURE - EASIEST WAY TO CONSUME "COVID-19" DATA

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:

  1. Repeat below Steps once every Day as those websites provide the latest data once every day
  2. Make HTTP Request
  3. Consume HTTP Response
  4. Convert HTTP Response to JSON Object
  5. using a loop, Massage each JSON Document and Convert it into Model class which represent a row/document in Azure Table/Cosmos DB
  6. Create Connection to Azure Table/Cosmos DB
  7. 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.

  1. create a Logic App in the Azure Portal. https://portal.azure.com/
    Alt text of image

  2. 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.
    Alt text of image

  3. 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/ .
    Alt text of image

  4. Consume Response of Step 3 and Convert it into JSON using Data Operations --> Parse JSON.

    Alt text of image

  5. 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.
    Alt text of image
    Alt text of image
    Alt text of image

  6. As our JSON data contains an array of documents, we need to loop through it, massage it and store it Cosmos.
    Alt text of image
    Alt text of image

  7. Massaging Data: Map your response JSON to new JSON document and add "ID" field in the new JSON document
    Alt text of image
    Alt text of image

  8. Connect to Cosmos DB, select Database and container ( table). Select Modified JSON Document in Document field, provide partition key-value field.
    Alt text of image
    Alt text of image

  9. Finally, Run logic App.
    Alt text of image
    Alt text of image

  10. Open Cosmos DB To check that data has been stored or not
    Alt text of image

hurray!!!!!!!!! It's working.
Alt text of image

I hope this post will help you.

Be Safe!! Spread Knowledge, Spread Love but Not Virus

Enjoy Azure & Enjoy Cloud Computing !!!!

Top comments (0)