locked
Run Function app in Logic app RRS feed

  • Question

  • I'm trying to run a Funtion app (C#) in Logic app and I have time-out problems.

    The Function app runs correctly and when it ends (between 2-5min.), it returns HttpStatusCode.OK (200), but the Logic app receives another status that makes that the Function app re-run another time (this process iterates about 5 times) until the Logic app fails and returns HttpStatusCode.BadRequest (400) with the message: "Http request failed: the timeout was reached."

    The function have the next configuration (function.json):

    {
      "bindings": [
        {
          "type": "httpTrigger",
          "direction": "in",
          "webHookType": "genericJson",
          "name": "req"
        },
        {
          "type": "http",
          "direction": "out",
          "name": "res"
        }
      ],
      "disabled": false
    }

    How can I configure my custom time-out?

    If Logic app gives the possibility to run a Function app 'natively', I think that's better to make a HTTP request, and manage the long running task with 202 until ends.

    Thanks in advance!


    • Edited by bcrespi Friday, August 12, 2016 4:34 PM
    Friday, August 12, 2016 4:34 PM

Answers

  • Yes you are running into two logic apps behaviors here.  The first is the retry-policy which sees a timeout error and by default retries (up to 3 additional times) the request.  The second is the HTTP timeout of 1 minute for the request to the Azure Function.  There are a few ways you can get around this:

    1. Invoke the async processing pattern to return a 202 ACCEPTED until the request is complete, and which point on a poll you return a 200 OK.  This would require your function to have some state somewhere of the current process for status check requests.

    2. Return a 202 Accepted and on completion output to something like a Service Bus Queue (or trigger a Logic App) so your original workflow doesn't have to "wait" for a response.

    3. Change to the webhook action which will send a callback URL to the function, which the function can call when it is done processing.

    Let me know and happy to help describe more details of any of these.

    Friday, August 12, 2016 5:18 PM

All replies

  • Yes you are running into two logic apps behaviors here.  The first is the retry-policy which sees a timeout error and by default retries (up to 3 additional times) the request.  The second is the HTTP timeout of 1 minute for the request to the Azure Function.  There are a few ways you can get around this:

    1. Invoke the async processing pattern to return a 202 ACCEPTED until the request is complete, and which point on a poll you return a 200 OK.  This would require your function to have some state somewhere of the current process for status check requests.

    2. Return a 202 Accepted and on completion output to something like a Service Bus Queue (or trigger a Logic App) so your original workflow doesn't have to "wait" for a response.

    3. Change to the webhook action which will send a callback URL to the function, which the function can call when it is done processing.

    Let me know and happy to help describe more details of any of these.

    Friday, August 12, 2016 5:18 PM
  • Hi, I am having the similar problem.

    In my case the workflow has to wait for the Azure Function to complete. My Azure function completed successfully, in 2 minutes. However, the LogicApp failed with the TimeOut error. I have set the Retry Policy to None. 

    Can I increase the time out ? What would be the easiest way for me to fix the issue.

    Thanks.

    Monday, December 11, 2017 4:11 PM
  • I recently wrote this blog post with some samples of options to get around it.

    https://medium.com/@jeffhollan/calling-long-running-functions-from-logic-apps-6d7ba5044701

    Monday, December 11, 2017 5:26 PM
  • Thanks for the quick response. I reviewed you blog post. I liked your approach to use HTTP Webhook that way I will not have to make to many changes in my current architecture. 

    I did some testing and was able to call the Azure Function using the HTTPWebHook. However, I am struggling with sending response back to Logic App to tell that the function execution is completed. I am using PowerShell Azure Function. Can you send me some reference that explains how to send the response back to HTTPWebHook ?

    Thanks ins advance.

    Monday, December 11, 2017 6:40 PM