从Azure逻辑应用程序触发的Web作业变得空闲

时间:2020-02-27 11:19:30

标签: c# azure console azure-webjobs azure-logic-apps

我正在尝试使用bulkdownload应用程序从blob下载大量文件,这是一个触发的网络作业,每3分钟运行一次。

有时运行时会变得空闲。抛出以下错误。

    [02/12/2020 09:20:34 > af14c2: SYS INFO] Status changed to Initializing
[02/12/2020 09:20:34 > af14c2: SYS INFO] Run script 'BulkDownload.exe' with script host - 'WindowsScriptHost'
[02/12/2020 09:20:34 > af14c2: SYS INFO] Status changed to Running
[02/12/2020 09:20:34 > af14c2: INFO] Bulk Download Process Started....
[02/12/2020 09:20:35 > af14c2: INFO] Getting BatchID From Header with Status  Pending and Failed
[02/12/2020 09:20:35 > af14c2: INFO] URL  https://testapp.com
[02/12/2020 09:20:35 > af14c2: INFO] Batch ID is  4
[02/12/2020 09:20:35 > af14c2: INFO] Batch Running is  1
[02/12/2020 09:20:35 > af14c2: INFO] Document Count in DetailQueue for this Batch is 35
[02/12/2020 09:20:35 > af14c2: INFO] 1
[02/12/2020 09:20:36 > af14c2: INFO] 2
[02/12/2020 09:20:37 > af14c2: INFO] 3
[02/12/2020 09:20:37 > af14c2: INFO] 4
[02/12/2020 09:24:38 > af14c2: ERR ] Command 'cmd /c ""BulkD ...' was aborted due to no output nor CPU activity for 120 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT 
app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""BulkDownload.exe""
[02/12/2020 09:24:39 > af14c2: SYS INFO] Status changed to Failed
[02/12/2020 09:24:39 > af14c2: SYS ERR ] System.AggregateException: One or more errors occurred. ---> Kudu.Core.Infrastructure.CommandLineException: Command 'cmd /c ""BulkD ...' 
was aborted due to no output nor CPU activity for 120 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""BulkDownload.exe""
   at Kudu.Core.Infrastructure.IdleManager.WaitForExit(IProcess process) in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\IdleManager.cs:line 45
   at Kudu.Core.Infrastructure.ProcessExtensions.<Start>d__13.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\ProcessExtensions.cs:line 254
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Kudu.Core.Infrastructure.Executable.<ExecuteAsync>d__31.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\Executable.cs:line 255
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Kudu.Core.Infrastructure.Executable.ExecuteInternal(ITracer tracer, Func`2 onWriteOutput, Func`2 onWriteError, Encoding encoding, String arguments, Object[] args) in
 C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\Executable.cs:line 216
   at Kudu.Core.Infrastructure.Executable.ExecuteReturnExitCode(ITracer tracer, Action`1 onWriteOutput, Action`1 onWriteError, String arguments, Object[] args) 
in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\Executable.cs:line 165
   at Kudu.Core.Jobs.BaseJobRunner.RunJobInstance(JobBase job, IJobLogger logger, String runId, String trigger, ITracer tracer, Int32 port) in C:\Kudu Files\Private\src\master\Kudu.Core\Jobs\BaseJobRunner.cs:line 272
---> (Inner Exception #0) ExitCode: -1, Output: Command 'cmd /c ""BulkD ...' was aborted due to no output nor CPU activity for 120 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed., Error: Command 'cmd /c ""BulkD ...' was aborted due to no output nor CPU activity for 120 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed., Kudu.Core.Infrastructure.CommandLineException: Command 'cmd /c ""BulkD ...' was aborted due to no output nor CPU activity for 120 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""BulkDownload.exe""
   at Kudu.Core.Infrastructure.IdleManager.WaitForExit(IProcess process) in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\IdleManager.cs:line 45
   at Kudu.Core.Infrastructure.ProcessExtensions.<Start>d__13.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\ProcessExtensions.cs:line 254
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Kudu.Core.Infrastructure.Executable.<ExecuteAsync>d__31.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\Executable.cs:line 255<---

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

为避免这种空闲情况,首先需要启用always on

您遇到这种情况,这是因为长时间运行的作业可能正在后台运行,但是对接SCM不知道。因此,您可以在应用程序服务中的configure下将WEBJOBS_IDLE_TIMEOUT(大部分就足够了)和/或SCM_COMMAND_IDLE_TIMEOUT(只需将它们两者都设置)设置为较高的值。这是秒数,直到Kudu杀死在给定时间段内没有任何请求或输出的WebJob为止的时间。您可以参考此doc