3

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
Lee
  • 1,591
  • 1
  • 14
  • 28

1 Answers1

3

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:

enter image description here

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:

enter image description here

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60
  • Interesting :) Next time I run into this I'll check out that time range filter. Now knowing where the error should show, if it doesn't, then I'll know to look at whether someone's changed default logging behaviour within the Function base code - thanks! – Lee Jul 02 '20 at 13:23
  • OMG, spent more than 3 month looking through solutions... f*** azure – Cute pumpkin Aug 01 '22 at 22:03