There are various articles/blogs/etc that compare logicapps vs flow vs functions vs azure automation, etc… Though there was one use case where I often struggled what to use ;
What to use when I want to retrieve a file from X on a Y timed interval?
Azure Functions? Great abstraction, though the output files have random names. Sometimes / Often I want to be able to control that.
Flow? Doesn’t allow the customization I was looking for. More to integrate existing / popular services.
Azure Automation? Very good and gets the job done. The only downside, you need to code a lot of logic yourself.
Azure Logic Apps? Shows potential, but doesn’t let you include custom functions. Or does it…?!?
You can link Azure Functions to Logic Apps and create some the flow I was looking for.
So what do I want to do?
- On a daily basis
- Retrieve content from an authenticated API
- Save the content to a Blob storage
And afterwards I’ll use other services to process that data. 🙂
What do I want to achieve? On a daily basis I want to retrieve data from a service provider that serves sports data. And if you are looking for such a thing, check out MySportsFeed! So back to our proof-of-concept; how will this look in Logic Apps?
Let’s dissect this flow…
Timed Interval / Trigger
So I want this flow to run on a daily basis… We’ll be using “Recurrence” as first step in our Logic App.
For the retrieval of the content, I’ll be using an HTTP (GET) call (with “basic” authentication, as supported by the API)
You’ll immediately notice that the URI is the content of one of a function… That is correct! I’ll be using Azure Functions to generate the parameters I need.
How do I go about with the Functions? Add an action and select “Azure Functions” ;
Click “Choose an Azure Function”
And … you’ll never guess this one … choose your Azure function! 😉
First select the plan, I had two here, where I’ll be using the one of “kvaesnhl”.
Then I’ll select the function that I want, being the one that generates the url for today’s scoreboard.
And one more thing… Afterwards, be sure to enter an input. Otherwise you’ll get errors. I did this by using a “dummy”-input ;
For this flow, I used two functions ;
- One to generate my daily url (with the data provider)
- One to generate my daily file name (for the blob storage)
And to be complete, I also used “kudu” to install the needed nodejs module “dateformat” ;
Saving the content onto Blob Storage
And for the last step… I’ll save the content (body) of the HTTP call with the name I generated in my second function.
That went quite smooth! Let’s run this baby… And we’ll see all steps receive a green check. Once we go to the storage account, we’ll see that the file has been created!
And it contains the needed information…