While working on Group provisioning process (blog here), we encountered an issue with parallel calls to Azure Functions from Flow. Even though, Microsoft flow supports sequencing flow runs but doesn’t queue them one after the other. Bummer !! However, we were able queued the requests at Azure Http function level, which was quite simple actually.
Azure Queue Triggers are mostly recommended in this case but with Queue trigger, the queue would always trigger at least two runs and the poison queue wouldn’t trigger after failing for more than 5 times
Hence we ended up managing it by the Http trigger function.
The process is quite simple and could be easily done by modifying the host.json file of the Azure function.
Note: Host.json is a global configuration file for all functions within a Function app, hence the below changes would affect all functions in that particular app.
Note: More details about host.json schema could be found in the Microsoft article here.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I created an Azure function which adds owner to the O365 group. And I call the Azure function from Microsoft flow.
When I run Azure function it is working fine but when I try to run the Azure function from Microsoft flow it is throwing error:
BadRequest. Http request failed: the timeout was reached.
In host.json, I added code as mentioned in this blog, but still I am getting error.
Hi, could you please paste the json and a screenshot of the flow step here ..
Thank you Ashish for your response.
I am unable to paste screenshot of my flow here.
Here is my host.json code:
I observed in few blogs that flow have Time limitation of 120 seconds. https://docs.microsoft.com/en-us/flow/limits-and-config
Can we increase it?
Yeah flow has limitations on wait for calls. Don’t think there is a way to extend it but you could actually make it an async with polling via Do untill loop until you get a success code (200) back. Here is a blog for the same. https://sergeluca.wordpress.com/2018/02/01/pattern-for-making-long-async-http-calls-in-microsoft-flow/
I updated my flow as suggested. But I am getting error.
I have attached my flow and error screenshots here: https://sharepoint261.wordpress.com/2019/02/22/flow-error/
Please reply to my above comment…
Hi Anjani, sorry busy here. Seems like something is wrong with your call. what kind of function is it and authentication. If Azure function is Function level authenticated, please make sure to add code to the Url. Can you put Azure function url here (remove the resource url)
Sorry for the late reply.
It is a Http trigger function and authentication will be taken care by the function itself.
I attached the function url and Timeout value screenshots in below link:
Please check and suggest.
My Azure function is working fine if I run my function independently. But when I run the Azure function from flow I am getting Timeout error in flow. I think the main issue is I couldn’t increase the time of flow.
Yeah increasing the HTTP time out doesn’t make any difference, I have seen that personally because it is a asynchronous poll. But I cannot see anything missing in your call unless your JSON request has an issue. Can you verify the JSON through JSONLint website? Also seems like it is breaking at your Azure Function level, returning a 400 error, can you please check that if the return call in your Azure Function is returning 200 or 202 on success. proper status code. Also will suggest Application logging on Azure Function and check the logs for error. Seems like Flow is doing the call but breaks on Azure Function
I received 200 on Azure function call.
I don’t think there is something wrong in Azure function because when I call my Azure function from flow, I am able to add owner to office 365 group successfully but getting timed out error in flow.
I attached screenshots in the end of the blog in below link:
Right, I suppose flow is not waiting for a reply from the Azure Function and moves to the next which then returns a failure (as user doesn’t exist) and captures that error. I suppose the best way would be to not use the Do until, and just call it and then use a callback value (list or something) to identify the job is done. Flow HTTP triggers are default Asynchronous behaviour so don’t wait synchronously beyond 2 min.
I saw a blog: https://veenstra.me.uk/2019/02/22/microsoft-flow-is-timeout-handling-your-worst-nightmare/
I think there is no way we can fix this.
Yes that’s right, we cannot change the timeouts, so the best way is to divide the jobs into smaller jobs or run parallel tasks in your job or just had over the task to Azure Function and handle the reply back using another flow. Pls check this blog for an idea – https://asishpadhy.com/2018/08/07/provisioning-complex-modern-sites-with-azure-functions-and-microsoft-flow-part-1-architecture/ (not exactly what you are doing but will give an idea)