在 Azure Functions 中启用异常
Enabling Exceptions in Azure Functions
我正在尝试调试我的 Azure Function App,但我得到的只是 "An error has occurred",这让解决我的问题变得极其困难。知道如何让应用程序返回完整的异常吗?任何使调试成为可能的东西,因为我现在被它大量阻止了。
非常感谢。
尼克。
编辑:在函数的 table 存储日志中,我看到以下错误,
...obs.Script.Description.FunctionInvokerBase.<Invoke>d__29.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.FunctionInvoker`1.<InvokeAsync>d__8.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.<InvokeAsync>d__22.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.<ExecuteWithWatchersAsync>d__21.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.<ExecuteWithLoggingAsync>d__19.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 inner exception stack trace ---
即使我在第一行手动抛出异常,我也会看到这个错误。真正的例外在哪里?
看着这些日志真的让我有时质疑微软的决定,这对任何人都有什么用?还是我在这里遗漏了一些重要的东西?
好的,这就是我的解决方案,这可能会因您遇到的问题而有所不同,因为该错误非常普遍。首先,我所做的是禁用我的函数的身份验证,以尝试让浏览器内编译器再次工作,因为自从我这样做以来,它就被破坏了,它没有帮助,它导致我的所有函数出现 404 错误。所以我再次启用它,这导致编译器开始工作!它表明我的 Azure 存储引用不匹配,我的 dll 以某种方式引用了 7.x 但在函数应用程序中期望 6.x,这很奇怪,因为我不记得曾经更改过它。无论如何,我创建了一个 project.json 文件,其中包含以下内容,
{
"frameworks": {
"net46":{
"dependencies": {
"WindowsAzure.Storage": "7.2.1"
}
}
}
}
上传到各个函数的文件夹后,又可以用了。我现在将通过 project.json 文件明确设置我所有的外部依赖项,希望能防止这种情况再次发生。
It's worth noting that although this doesn't make the full exception
get returned in-browser, it did enable me to see compiler errors,
which is what was causing the issue and preventing me from handling
any exceptions in the function app.
-
One last note and to show how buggy Azure Function Apps are, even
though Authentication is "enabled" according to the app settings, it's
not working, this is why the in-browser compiler is now working. I'm
working on getting it working again, but won't be replying to this
thread anymore. Just be wary.
我正在尝试调试我的 Azure Function App,但我得到的只是 "An error has occurred",这让解决我的问题变得极其困难。知道如何让应用程序返回完整的异常吗?任何使调试成为可能的东西,因为我现在被它大量阻止了。
非常感谢。
尼克。
编辑:在函数的 table 存储日志中,我看到以下错误,
...obs.Script.Description.FunctionInvokerBase.<Invoke>d__29.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.FunctionInvoker`1.<InvokeAsync>d__8.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.<InvokeAsync>d__22.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.<ExecuteWithWatchersAsync>d__21.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.<ExecuteWithLoggingAsync>d__19.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 inner exception stack trace ---
即使我在第一行手动抛出异常,我也会看到这个错误。真正的例外在哪里?
好的,这就是我的解决方案,这可能会因您遇到的问题而有所不同,因为该错误非常普遍。首先,我所做的是禁用我的函数的身份验证,以尝试让浏览器内编译器再次工作,因为自从我这样做以来,它就被破坏了,它没有帮助,它导致我的所有函数出现 404 错误。所以我再次启用它,这导致编译器开始工作!它表明我的 Azure 存储引用不匹配,我的 dll 以某种方式引用了 7.x 但在函数应用程序中期望 6.x,这很奇怪,因为我不记得曾经更改过它。无论如何,我创建了一个 project.json 文件,其中包含以下内容,
{
"frameworks": {
"net46":{
"dependencies": {
"WindowsAzure.Storage": "7.2.1"
}
}
}
}
上传到各个函数的文件夹后,又可以用了。我现在将通过 project.json 文件明确设置我所有的外部依赖项,希望能防止这种情况再次发生。
It's worth noting that although this doesn't make the full exception get returned in-browser, it did enable me to see compiler errors, which is what was causing the issue and preventing me from handling any exceptions in the function app.
-
One last note and to show how buggy Azure Function Apps are, even though Authentication is "enabled" according to the app settings, it's not working, this is why the in-browser compiler is now working. I'm working on getting it working again, but won't be replying to this thread anymore. Just be wary.