本文介绍了队列触发的Azure Webjob的时间限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure Web作业中的队列触发功能是否有任何时间限制.我的函数大约需要20-30分钟,因为它需要遍历数据库中的许多记录.最后的功能状态为永不结束".我将{."stopping_wait_time":1800}放入settings.job文件-没有任何效果.但是在五分钟左右的时间内,其状态将设置为永不结束".我搜索了,是的,发现有人问类似的问题-没有明确的答案.我在日志中发现了一些异常,这些异常似乎是从Azure存储生成的.我搜索后发现日志记录存在一些问题,因此我注释掉了函数中的日志记录代码-仍然行不通.我也发现了一个提到一些连接字符串的问题-现在我有了这些. AzureWebJobsStorage,AzureWebJobsDashboard,AzureJobsRuntime,AzureJobsData-都指向同一个存储帐户-仍然行不通.

Are there any time limits on the queue triggered function inside an azure web job. My function takes about 20-30 mins since it needs to go over a lot of records in the DB. The function status in the end is Never Finished. I put in the settings.job file with { "stopping_wait_time": 1800 } - with no effect. But within five minutes or so its status is set to Never Finished. I searched and yes found some ppl asking similar questions - with no definitive answers. I found some exceptions in the logs and the exceptions seemed to be generated from Azure storage. I searched and found there were some issues with logging, so i commented out logging code within the function - still no go. Also i found one question that mentioned some connection strings - so now i have these; AzureWebJobsStorage, AzureWebJobsDashboard, AzureJobsRuntime, AzureJobsData - all pointing to the same storage account - still no go.

我尝试调试,看看超时发生在哪里,甚至在我的函数真正被执行之前,它似乎正在发生,

I tried to debug, and see where the timeout occurs and it seems like it is happening even before my function is actually hit,

输出如下所示;

A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.TimeoutException' occurred in Microsoft.WindowsAzure.Storage.dll
A first chance exception of type 'Microsoft.WindowsAzure.Storage.StorageException' occurred in Microsoft.WindowsAzure.Storage.dll
A first chance exception of type 'Microsoft.WindowsAzure.Storage.StorageException' occurred in Microsoft.WindowsAzure.Storage.dll
A first chance exception of type 'Microsoft.WindowsAzure.Storage.StorageException' occurred in mscorlib.dll
A first chance exception of type 'Microsoft.WindowsAzure.Storage.StorageException' occurred in mscorlib.dll
A first chance exception of type 'Microsoft.WindowsAzure.Storage.StorageException' occurred in Microsoft.Azure.WebJobs.Host.dll
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>PnCProcessor.exe</AppDomain><Exception><ExceptionType>Microsoft.WindowsAzure.Storage.StorageException, Microsoft.WindowsAzure.Storage, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</ExceptionType><Message>The client could not finish the operation within specified timeout.</Message><StackTrace>   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result)
at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.EndExists(IAsyncResult asyncResult)
at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.&amp;lt;&amp;gt;c__DisplayClass1`1.&amp;lt;CreateCallback&amp;gt;b__0(IAsyncResult ar)
--- 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 Microsoft.Azure.WebJobs.Host.Queues.Listeners.QueueListener.&amp;lt;ExecuteAsync&amp;gt;d__4.MoveNext()
--- 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 Microsoft.Azure.WebJobs.Host.Timers.TaskSeriesTimer.&amp;lt;RunAsync&amp;gt;d__d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Azure.WebJobs.Host.Timers.BackgroundExceptionDispatcher.&amp;lt;&amp;gt;c__DisplayClass1.&amp;lt;Throw&amp;gt;b__0()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>Microsoft.WindowsAzure.Storage.StorageException: The client could not finish the operation within specified timeout. ---&amp;gt; System.TimeoutException: The client could not finish the operation within specified timeout.
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result)
at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.EndExists(IAsyncResult asyncResult)
at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.&amp;lt;&amp;gt;c__DisplayClass1`1.&amp;lt;CreateCallback&amp;gt;b__0(IAsyncResult ar)
--- 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 Microsoft.Azure.WebJobs.Host.Queues.Listeners.QueueListener.&amp;lt;ExecuteAsync&amp;gt;d__4.MoveNext()
--- 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 Microsoft.Azure.WebJobs.Host.Timers.TaskSeriesTimer.&amp;lt;RunAsync&amp;gt;d__d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Azure.WebJobs.Host.Timers.BackgroundExceptionDispatcher.&amp;lt;&amp;gt;c__DisplayClass1.&amp;lt;Throw&amp;gt;b__0()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Request Information
RequestID:
RequestDate:
StatusMessage:
</ExceptionString><InnerException><ExceptionType>System.TimeoutException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>The client could not finish the operation within specified timeout.</Message><StackTrace>   at Microsoft.Azure.WebJobs.Host.Timers.BackgroundExceptionDispatcher.&amp;lt;&amp;gt;c__DisplayClass1.&amp;lt;Throw&amp;gt;b__0()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

System.TimeoutException:客户端无法在指定的超时时间内完成操作.

System.TimeoutException: The client could not finish the operation within specified timeout.

我正在为此使用S1 Web应用程序和标准GRS存储帐户.

I am using a S1 web app and a standard-GRS storage account for this.

问题就是这样;
1.队列触发功能花费的时间是否有时间限制?
2.如果有时间限制,有什么办法可以克服这些限制?
3.我必须使用队列触发的函数,因为我需要将一些参数传递给该函数-这些参数是从另一个计划的Web作业传递的.我可以按需制作Webjob并在命令行上传递参数-但是有没有办法从计划的Webjob调用按需Webjob?

So questions are;
1. Are there any time limitations on the time the queue triggered function takes?
2. If there are time limitations is there any way to override those?
3. I have to use a queue triggered function since i need to pass some parameters to the function - which are passed from another scheduled web job. I can make an on-demand webjob and pass the parameters on the command line - but then is there a way to call an on-demand webjob from a scheduled webjob?

感谢您的帮助!

推荐答案

对队列触发的作业功能的执行时间没有限制.但是,您需要确保设置正确,以便您的JobHost继续运行.使用Azure WebJobs SDK时,需要将JobHost控制台exe部署为连续运行的WebJob ,并启用始终在线. 此文档中对此都有详细描述页在创建连续运行的Web作业"部分下.

No there is no limit on execution time of queue triggered job functions. However there are a few things you have to ensure you set up properly so your JobHost continues to run. When using the Azure WebJobs SDK you need to deploy your JobHost Console exe as a continuously running WebJob, and enable Always On. Both of those are described in detail on this documentation page under the "Create a continuously running WebJob" section.

有关在免费层(20分钟超时)中运行的超时限制的相关详细信息,请参阅该页面的注释"部分,可以通过移至基本或标准层来删除超时限制.

See the "Notes" section of that page for relevant details on the timeout limits when running in the Free tier (20 minute timeout), which can be removed by moving to Basic or Standard tier.

这篇关于队列触发的Azure Webjob的时间限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 19:28