Share via


Azure logic app async polling pattern

Question

Saturday, June 16, 2018 1:24 PM

I am trying out a scenario in which i have a long running external API from which I have to retrieve data. I have the API return 202 status code along with location header once the process has been initiated.  But the logic app engine does not seem to recognize the response code and continues execution even though it should have kept polling the url in location header until 200 is returned.

Any help is really appreciated. Any sample logic app that showcases this pattern can help.

All replies (6)

Saturday, June 16, 2018 6:53 PM

Hi,

Here are the few artciles which explains it

https://sergeluca.wordpress.com/2018/02/01/pattern-for-making-long-async-http-calls-in-microsoft-flow/

https://blogs.msdn.microsoft.com/derekli/2017/12/04/use-api-m-to-mask-async-apis-when-moving-implementation-to-logic-appsfunctions/

if you are using HTTP action to call your External API then you have to Check the status code and Poll it again. The above articles explains it.

Sujith


Sunday, June 17, 2018 3:24 PM

As per description given under the Asynchronous Pattern settings, Logic app engine will automatically poll the Url given in location header until 200 status code is returned. It might not require the developer having to add an action explicitly to invoke the url given in location header.

This is as per details in blog:

https://blogs.msdn.microsoft.com/logicapps/2016/02/15/long-running-tasks-in-logic-apps/

Asynchronous Pattern section under HTTP action in microsoft document:

https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-actions-triggers#http-action

Kindly revert if the above has been mis-stated


Sunday, June 17, 2018 7:33 PM

Thanks for Pointing out, once let me try and get back to you

Sujith


Sunday, June 17, 2018 9:38 PM

Hi AzureLearner,

Here is a post from Jeff Hollan that explains how the API should look like. In this post, he states that you don't have to do anything else - the engine should take care of that. I've checked and the HTTP action have async pattern enabled by default. So in summary you just need a plain HTTP action for that. The whole work must be done by the api on the other side (supplying 202 + location header and retry after headers).

There is another post from Jeff suggesting different approaches (but that seems to be specific to integration with functions - but it might give you ideas, so I am adding it here just in case.

I hope this helps, Wagner.


Monday, June 18, 2018 4:29 PM | 1 vote

I have a logic app calling a long running app service (which calls a SQL proc which can take up to an hour to process, which was why I had to do it!) all based on Jeff's example - it works like a champ.


Monday, June 18, 2018 8:37 PM

Yesterday I also executed a long running process (a Azure management API that was backing up an API Management instance) via logic app, and the async patterns also worked as expected, without any extra configuration on the logic app side. So it probably proves the point that the main thing is to create the API code that will be consumed by the logic apps in the correct format.

Cheers, Wagner.