gpt4 book ai didi

Azure WebJob 服务总线触发器无法完成

转载 作者:行者123 更新时间:2023-12-03 04:25:28 25 4
gpt4 key购买 nike

我有一个 Azure WebJob 设置为连续运行,它使用服务总线触发器来读取队列和主题。当队列被处理时,消息被发送到一个主题中,我有一个主题来管理缓存更新。

我暂时通过从函数返回来禁用缓存更新,以便将消息从主题中清除。

public static void ProcessSearchUpdate([ServiceBusTrigger("events", "SearchClientUpdates", AccessRights.Listen)] BrokeredMessage message, System.IO.TextWriter log)
{
return;
}

大多数时候,事情都会按计划进行,消息只是被读取并丢弃。但是,有时,我会遇到以下异常,我假设是 webjobs sdk 尝试写入日志时出现的异常。

如您所见,我的方法没有执行任何操作,因此不应超时。

当它失败时,它会阻止任何触发器执行,这非常烦人。看来 SDK 中的任何故障都有 5 分钟超时,并且它会阻止任何内容在 5 分钟内运行,再加上重新启动时间。

Microsoft.WindowsAzure.Storage.StorageException: Microsoft.WindowsAzure.Storage.StorageException: The client could not finish the operation within specified timeout. ---> System.TimeoutException: The client could not finish the operation within specified timeout.
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.Storage.Core.Util.StorageAsyncResult`1.End() in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\StorageAsyncResult.cs:line 77
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.EndUploadFromStream(IAsyncResult asyncResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlockBlob.cs:line 774
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.EndUploadFromByteArray(IAsyncResult asyncResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlockBlob.cs:line 1162
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.EndUploadText(IAsyncResult asyncResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlockBlob.cs:line 1285
at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass4.<CreateCallbackVoid>b__3(IAsyncResult ar) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.cs:line 114
--- 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.Loggers.UpdateOutputLogCommand.<UpdateOutputBlob>d__10.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.Loggers.UpdateOutputLogCommand.<SaveAndCloseAsync>d__6.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 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithLoggingAsync>d__13.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.Executors.FunctionExecutor.<TryExecuteAsync>d__1.MoveNext()
Request Information
RequestID:
RequestDate:
StatusMessage:

最佳答案

与WebJob日志系统相关的异常。 Azure WebJob SDK 会定期将日志刷新到 blob 存储。为了解决超时问题,我们可以增加 WebJob SDK 为此使用的 CloudBlobClient 的超时值。以下步骤供您引用。

步骤 1. 使用 NuGet 将 Microsoft.Azure.WebJobs 的版本更新到 2.0.0。

enter image description here

第2步.实现我们自己的StorageClientFactory,它可以重置blob客户端的超时值。

public class MyStorageClientFactory : Microsoft.Azure.WebJobs.Host.StorageClientFactory
{
public override CloudBlobClient CreateCloudBlobClient(StorageClientFactoryContext context)
{
CloudBlobClient client = context.Account.CreateCloudBlobClient();
client.DefaultRequestOptions.ServerTimeout = TimeSpan.FromMinutes(60);
return client;
}
}

第3步.让JobHost使用自定义的StorageClientFactory。

JobHostConfiguration configuration = new JobHostConfiguration();
configuration.StorageClientFactory = new MyStorageClientFactory();

var host = new JobHost(configuration);

关于Azure WebJob 服务总线触发器无法完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43969713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com