Where can exceptions raised within FunctionsStartup.Configure be found logged on Azure?

三世轮回 提交于 2021-02-11 14:21:46

问题


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.

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);
    }
...

I've looked in the following places:

Diagnose and solve problems / Function App Down or Reporting Errors:

  • Reports a stale error, doesn't seem to be updated each time the above error is raised.

AppInsights:

  • "Your app is offline or the Application Insights SDK needs updating."

Kudu:

  • D:\home\LogFiles\eventlog.xml - Can't see anything meaningful here
  • D:\home\LogFiles\Application\Functions\Function\FunctionName\*.log - No files for today
  • D:\home\LogFiles\Application\Functions\Host\*.log - No files for today

Storage account file shares:

  • One modified with today's date
  • /LogFiles/ - Empty
  • /site/wwwroot/ - Empty

回答1:


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:

Step 1. Nav to azure portal -> your function app -> click on the Diagnose and solve problems blade -> 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:

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:



来源:https://stackoverflow.com/questions/62657579/where-can-exceptions-raised-within-functionsstartup-configure-be-found-logged-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!