1
votes

Like the title describes - I have an Azure Function on the App Service Plan, configured for Always On and no functionTimeout set in my host.json, and it appears to timeout / not finish anytime after 30 minutes to 1 hour.(...but I feel this may be a false positive...)

The HTTP Triggered function can sometimes take over 1-2 hours to complete. I understand that this probably isn't the best design and according to the Azure Function Best Practices I should break this out into smaller / more manageable pieces - I get that. However, I expect the Function on the App Service plan to work as advertised - no hard limit on execution time. Perhaps this is the same question as Unexpected azure-function timeouts on app-service-plan, but that has no answer and I am using an HTTP Trigger instead.

Currently, the HTTP Triggered method does not return until the work is complete. (Is this a problem - the HTTP trigger needs to return quicker?)

According to the Kudu Function Invocation Logs, this case reports "Never Finished", and when I click on the Toggle Output button to view the logs, they never come in.

KUDO Invocation Details

When I viewed this function's run in the Logs section of that trigger, it seems like the function just stopped, and the log stream just reports no new trace:

2017-07-26T16:36:43.116 [INFO] [Class1] Update operation started processing 790 sales records ... 2017-07-26T16:36:43.116 [DBUG] [Class2] Matching and updating ids from the map... 2017-07-26T16:38:07 No new trace in the past 1 min(s). 2017-07-26T16:39:07 No new trace in the past 2 min(s). 2017-07-26T16:40:07 No new trace in the past 3 min(s). 2017-07-26T16:41:07 No new trace in the past 4 min(s).

So not sure why this function just seemed to stop - or perhaps it stopped collecting log statements (there are many), and for some reason, the function never completed.

Any ideas?

Approx time: 2017-07-26T16:00:00 UTC InvocationID: d856c107-f1ee-455a-892b-ed970dcad128 (I think?)

If it is indeed being timed out, is there any way for us to know, (Exception? App Insights? etc.)

3
Dear lord I feel sorry for the client that initiated that HTTP request... - Jesse Carter
@JesseCarter we just use the HTTP trigger for manual testing.. - flyte
At the bare minimum the HTTP trigger should place a work item in a queue to kick off another function to do the actual processing. You get the benefit of automatic retries and auditing through poison queues as well - Jesse Carter
@JesseCarter - understood and I even mention my current approach isn't ideal in my question text. The question is still valid - why is my app service plan function seemingly timing out? - flyte
An HTTP request can't just be kept alive indefinitely. For all you know the client is timing it out because you aren't responding in an appropriate amount of time. You have massive design flaws in your system that need to be addressed, this is just a red herring - Jesse Carter

3 Answers

1
votes

Based on my test, I found azure function will not stop your function if you don't set the timeout.

Here is my test, I create a ManualTrigger function which will log the message every 10 minutes.

The codes like below:

public static void Run(string input, TraceWriter log)
{

       for (int i = 0; i < 100; i++)
            {

                log.Info( "Worked " + i*10 + " minutes ");
                Thread.Sleep(600000);
            }

}

The log details:

enter image description here

In the log, you could find my function executed 70 minutes.It still works well.

The no trace means there are no new requests send to the azure function.

Currently, the HTTP Triggered method does not return until the work is complete. (Is this a problem - the HTTP trigger needs to return quicker?)

As Jesse Carter says, you couldn't execute long time function when you used HTTP Triggered method.

Since your client-side(send request) will have a timeout value. It will wait for the function's response.

Normally, if we want to execute long time function, I suggest you could use http trigger to get the request. In the http trigger function you could add a queue message to the azure storage queue.

Then you could write a queue trigger function which will execute the long time work.

1
votes

If your HTTP method takes more than a minute, you should be offloading it to a Queue. Period. (I know the other answers have said this, but it's worth repeating).

  1. Http connections are a limited resource.
  2. While Azure Functions as an execution engine can handle long running operations (as demonstrated by queue / service bus support), the http pipeline may cut off / timeout long running requests.

Queue triggers can easily run for 30+ minutes. If your job is longer than that, you really should split it into multiple queue messages.

Also check out Durable Function support: https://github.com/Azure/azure-functions-durable-extension/

0
votes

Regardless of the function app timeout setting, 230 seconds is the maximum amount of time that an HTTP triggered function can take to respond to a request. This is because of the default idle timeout of Azure Load Balancer. For longer processing times, consider using the Durable Functions async pattern or defer the actual work and return an immediate response. Function app timeout duration: Check Notes