问题描述
在下面的代码中,Azure中记录的错误在哪里?有时,此类错误的原因很难识别,并导致功能主机未运行".'无法找到记录的异常.
In the following code, where is the error logged in Azure? Sometimes the cause of such an error is difficult to identify, and results in "Function host is not running.", I've not been able to find the logged exception.
之前,我已经通过向BlobStorage编写自己的try/catch日志来解决此问题,但是,我希望有一种更惯用的方式来获取异常.
I've worked around this before by writing my own try/catch logging to BlobStorage myself, however, I'd hope there's a more idiomatic way of obtaining the exception.
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
throw new Exception("Boom!");
ConfigureServices(builder.Services);
}
...
我看过以下地方:
诊断并解决问题/功能关闭或报告错误:
Diagnose and solve problems / Function App Down or Reporting Errors:
- 报告一个过时的错误,似乎不会在每次出现上述错误时进行更新.
AppInsights:
AppInsights:
- 您的应用程序处于离线状态,或者Application Insights SDK需要更新."
Kudu:
- D:\ home \ LogFiles \ eventlog.xml-在这里看不到任何有意义的内容
- D:\ home \ LogFiles \ Application \ Functions \ Function \ FunctionName \ *.log-今天没有文件
- D:\ home \ LogFiles \ Application \ Functions \ Host \ *.log-今天没有文件
存储帐户文件共享:
- 用今天的日期修改的一个
- /LogFiles/-空
- /site/wwwroot/-空
推荐答案
您可以按照以下步骤从Startup.cs中检查异常日志.
You can check the exception logs from Startup.cs as per steps below.
首先,这是我的测试代码:
First, this is my test code:
[assembly: FunctionsStartup(typeof(FunctionApp11.Startup))]
namespace FunctionApp11
{
public class Startup: FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
throw new Exception("xxxx haha an error is occuring....");
}
}
}
在天蓝色门户中运行天蓝色功能之后,请按照以下步骤操作:
After the azure function running in azure portal, please follow these steps:
第1步.导航至天蓝色门户->您的功能应用程序->点击诊断并解决问题刀片->然后在搜索框中输入功能应用向下->然后您会看到 Function App Down或Reporting Errors (功能应用程序关闭或报告错误),点击该按钮.屏幕截图如下:
Step 1. Nav to azure portal -> your function app -> click on the Diagnose and solve problemsblade -> Then input function app down in the search box -> then you can see Function App Down or Reporting Errors appears, click on it. The screenshot as below:
步骤2.在功能应用程序关闭或报告错误" 页面中,展开功能执行和错误->.然后在功能应用中离线展开检测到的主机.->最后,您可以在此处看到异常日志(如果没有错误日志,请考虑在页面中更改时间范围).屏幕截图如下:
Step 2. In the Function App Down or Reporting Errors page, expand Function Executions and Errors -> then expand Detected host offline in your function app. -> at last, you can see the exception logs there(if no error logs, consider to change the time range in the page). The screenshot as below:
这篇关于在Azure上哪里可以找到在FunctionsStartup.Configure中引发的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!