异常 Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException
Posted
技术标签:
【中文标题】异常 Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException【英文标题】:EXCEPTION Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException 【发布时间】:2022-01-18 19:02:33 【问题描述】:我最近正在开发一个使用 ServiceBus 工作的 Azure 函数。但是,当我们在开发环境中进行测试时,它可以完美运行,当我们投入生产时,会发生一些错误并生成我无法调试和理解的堆栈跟踪器,有人可以帮助我吗?我在下面留下堆栈跟踪供您查看。
Exception while executing function: Functions.RunBlobMigration Result: Failure
Exception: System.AggregateException: One or more errors occurred. (An error occurred while writing to logger(s). (Value cannot be null. (Parameter 'value')))
---> System.AggregateException: An error occurred while writing to logger(s). (Value cannot be null. (Parameter 'value'))
---> System.ArgumentNullException: Value cannot be null. (Parameter 'value')
at Google.Protobuf.ProtoPreconditions.CheckNotNull[T](T value, String name)
at Microsoft.Azure.Functions.Worker.Grpc.Messages.RpcLog.set_Message(String value) in D:\a\1\s\src\DotNetWorker.Grpc\obj\Release\net5.0\FunctionRpc.cs:line 8976
at Microsoft.Azure.Functions.Worker.Logging.GrpcFunctionsHostLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) in D:\a\1\s\src\DotNetWorker.Grpc\GrpcFunctionsHostLogger.cs:line 46
at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[TState](LogLevel logLevel, EventId eventId, ILogger logger, Exception exception, Func`3 formatter, List`1& exceptions, TState& state)
--- End of inner exception stack trace ---
at Microsoft.Extensions.Logging.Logger.ThrowLoggingError(List`1 exceptions)
at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
at Microsoft.Extensions.Logging.Logger`1.Microsoft.Extensions.Logging.ILogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
at Microsoft.Extensions.Logging.LoggerExtensions.LogMetric(ILogger logger, String name, Double value, IDictionary`2 properties) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Loggers\Logger\LoggerExtensions.cs:line 33
at ThomsonReuters.DocMi.BlobMigration.Execution.AzureFunctions.Functions.BlobMigration.RunBlobMigration.LogBlobExecutionMetric(ILogger log, BlobMigrationStrategyIdentifier blobMigrationStrategyIdentifier, ControlMetadataEntity controlMetadataEntity, BlobMetadataEntity blobMetadataEntity, Int64 elapsedMilliseconds, Nullable`1 fileSizeInBytes) in /home/runner/work/DocMi_Functions/DocMi_Functions/src/BlobMigration/ExecutionServices/ThomsonReuters.DocMi.BlobMigration.Execution.AzureFunctions/Functions/BlobMigration/RunBlobMigration.cs:line 189
at ThomsonReuters.DocMi.BlobMigration.Execution.AzureFunctions.Functions.BlobMigration.RunBlobMigration.RunAsync(String messageBrokerMessageString, FunctionContext context) in /home/runner/work/DocMi_Functions/DocMi_Functions/src/BlobMigration/ExecutionServices/ThomsonReuters.DocMi.BlobMigration.Execution.AzureFunctions/Functions/BlobMigration/RunBlobMigration.cs:line 162
at Microsoft.Azure.Functions.Worker.Invocation.VoidTaskMethodInvoker`2.InvokeAsync(TReflected instance, Object[] arguments) in D:\a\1\s\src\DotNetWorker.Core\Invocation\VoidTaskMethodInvoker.cs:line 22
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionInvoker`2.<>c.<InvokeAsync>b__6_0(Task`1 t) in D:\a\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionInvoker.cs:line 32
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\a\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionExecutor.cs:line 44
at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13
at Microsoft.Azure.Functions.Worker.GrpcWorker.InvocationRequestHandlerAsync(InvocationRequest request, IFunctionsApplication application, IInvocationFeaturesFactory invocationFeaturesFactory, ObjectSerializer serializer, IOutputBindingsInfoProvider outputBindingsInfoProvider) in D:\a\1\s\src\DotNetWorker.Grpc\GrpcWorker.cs:line 167
Stack: at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionInvoker`2.<>c.<InvokeAsync>b__6_0(Task`1 t) in D:\a\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionInvoker.cs:line 32
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\a\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionExecutor.cs:line 44
at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13
at Microsoft.Azure.Functions.Worker.GrpcWorker.InvocationRequestHandlerAsync(InvocationRequest request, IFunctionsApplication application, IInvocationFeaturesFactory invocationFeaturesFactory, ObjectSerializer serializer, IOutputBindingsInfoProvider outputBindingsInfoProvider) in D:\a\1\s\src\DotNetWorker.Grpc\GrpcWorker.cs:line 167
如果您需要更多信息,我随时为您服务。
谢谢。
【问题讨论】:
【参考方案1】:RpcException 是一个非常普遍的错误,可能存在潜在问题。
当函数执行失败并且异常以Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: Failure
开头时,看起来这应该是平台错误,而在几乎所有情况下,它都是来自用户代码的异常堆栈失败。
尝试重启函数应用。
https://github.com/Azure/azure-functions-host/issues/6284#issue-647616617
https://github.com/Azure/azure-functions-host/issues/4192#issuecomment-481813144
【讨论】:
以上是关于异常 Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException的主要内容,如果未能解决你的问题,请参考以下文章
Kotlin 协程协程异常处理 ① ( 根协程异常处理 | 自动传播异常 | 在协程体捕获异常 | 向用户暴露异常 | 在 await 处捕获异常 | 非根协程异常处理 | 异常传播特性 )
Kotlin 协程协程异常处理 ① ( 根协程异常处理 | 自动传播异常 | 在协程体捕获异常 | 向用户暴露异常 | 在 await 处捕获异常 | 非根协程异常处理 | 异常传播特性 )