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.


{
"http": {
"routePrefix": "api",
"maxOutstandingRequests": -1,
"maxConcurrentRequests": 1,
"dynamicThrottlesEnabled": false
}
}

17 Comments

  1. Hi,
    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.

    Kindly suggest.

    Like

  2. 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)

    Like

  3. 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:
    https://sharepoint261.wordpress.com/2019/02/22/flow-error/
    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.

    Like

    1. 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

      Like

    1. 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.

      Like

    1. 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)

      Like

Leave a comment