问题
some of my continuous running web job function(random) show message of Timeout value of 00:30:00 exceeded by function '<myfunction>' (Id: '<id>'). Initiating cancellation.
after this message this function will not execute itself until and unless manually stop and start the azure web job.
Thanks in advance.
回答1:
some of my continuous running web job function(random) show message of
Timeout value of 00:30:00 exceeded by function '<myfunction>' (Id: '<id>'). Initiating cancellation.
Based on your error, I found the related code from Microsoft.Azure.WebJobs.Host under FunctionExecutor.cs as follows:
internal static void OnFunctionTimeout(System.Timers.Timer timer, FunctionDescriptor method, Guid instanceId, TimeSpan timeout, bool timeoutWhileDebugging,
    TraceWriter trace, ILogger logger, CancellationTokenSource cancellationTokenSource, Func<bool> isDebuggerAttached)
{
    timer.Stop();
    bool shouldTimeout = timeoutWhileDebugging || !isDebuggerAttached();
    string message = string.Format(CultureInfo.InvariantCulture,
        "Timeout value of {0} exceeded by function '{1}' (Id: '{2}'). {3}",
        timeout.ToString(), method.ShortName, instanceId,
        shouldTimeout ? "Initiating cancellation." : "Function will not be cancelled while debugging.");
    trace.Error(message, null, TraceSource.Execution);
    logger?.LogError(message);
    trace.Flush();
    // Only cancel the token if not debugging
    if (shouldTimeout)
    {
        // only cancel the token AFTER we've logged our error, since
        // the Dashboard function output is also tied to this cancellation
        // token and we don't want to dispose the logger prematurely.
        cancellationTokenSource.Cancel();
    }
}
I assumed that you specified the TimeoutAttribute for your function as follows:
I would recommend you could use a CancellationToken parameter in your function and it would be canceled whenever a timeout occurs or host shutdown, and you could exit your function gracefully as follows:
来源:https://stackoverflow.com/questions/45543191/azure-web-job-failing-to-execute-after-timeout