【发布时间】:2017-03-22 08:44:17
【问题描述】:
我有一个函数侦听经常插入的 blob 存储,但有时很少足以让函数空闲。
它的设置方式是在 bin 文件夹中包含一些自定义 DLL,而实际函数本身只是在其中一个程序集中调用 run 方法。这工作正常。大多数时候。
我的问题是,如果我让它运行一段时间,它会突然无法加载我的自定义程序集,并显示以下错误消息:
Exception while executing function: Functions.EventHandlerFunctionMicrosoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.EventHandlerFunction ---> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ---> System.TypeLoadException : Could not load type 'MyAssembly.MyFunctions.EventHandlerFunction' from assembly 'MyAssembly.MyFunctions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. at async Submission#0.Run(Stream blob,String name,TraceWriter log) at : 19 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine) at Submission#0.Run(Stream blob,String name,TraceWriter log) End of inner exception at System.RuntimeMethodHandle.InvokeMethod(Object target,Object[] arguments,Signature sig,Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object[] parameters,Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object[] parameters,CultureInfo culture) at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.InvokeCore(Object[] parameters,FunctionInvocationContext context) at async Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`1.InvokeAsync[TReflected](Object[] arguments) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,Object[] invokeParameters,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,IReadOnlyDictionary`2 parameters,TraceWriter traceWriter,CancellationToken…
从堆栈跟踪中可以看出,我的程序集(重命名为 MyAssembly.MyFunctions)突然无法加载。它会自行恢复,但停机时间和“丢弃”的 blob 大约是我 blob 的 1/5。
这看起来很愚蠢。虽然我意识到我可以通过对该异常做出反应并重新插入 blob 来缓解这种情况,但这似乎是一种资源浪费。
我的猜测是,azure 函数运行时有时会在空闲后无法加载 dll。有没有人遇到过这种情况并找到解决方法?
更新:我的函数如下所示:
#r "MyAssembly.MyFunctions.dll"
public static async Task Run(Stream blob, string name, TraceWriter log)
{
try {
await new EventHandlerFunction().Run(name);
} catch (Exception e) {
log.Error(e.Message);
}
}
【问题讨论】:
-
或许直接在github上打开这个是个好主意github.com/Azure/Azure-Functions
-
是的,我想过这个,但我想我会先在这里试一两天。
-
绝对不是预期的行为。您能否分享您的函数应用名称或执行 ID,以便我们仔细看看这里发生了什么?
-
对于任何关注的人,现在正在这里调查:github.com/Azure/azure-webjobs-sdk-script/issues/1338
标签: c# .net azure azure-functions