Azure Web作业在超时后无法执行

编程入门 行业动态 更新时间:2024-10-25 22:32:13
本文介绍了Azure Web作业在超时后无法执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的一些连续运行的Web作业功能(随机)显示消息超时值00:30:00被功能'< myfunction>'超出(Id:< id>").开始取消.

此消息后,除非手动停止并启动Azure Web作业,否则此功能将不会自行执行.

谢谢.

解决方案

我的一些连续运行的Web作业功能(随机)显示消息超时值00:30:00被功能'< myfunction>'超出(Id:< id>").开始取消.

根据您的错误,我在

我建议您可以在函数中使用 CancellationToken 参数,并在发生超时或主机关闭时将其取消,并且可以按以下方式正常退出函数:

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.

解决方案

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:

更多推荐

Azure Web作业在超时后无法执行

本文发布于:2023-11-24 03:19:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623782.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   Azure   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!