Azure web job failing to execute after timeout

邮差的信 提交于 2021-02-08 09:35:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!