Azure Api App failing on startup with 500.30

When the app startup fails, it does so silently. Or effectivly silently: complaining without providing relevant information. This is the IIS complain

<body>
        <h1> HTTP Error 500.30 - ANCM In-Process Start Failure </h1>

        <h2> Common solutions to this issue: </h2><ul><li>The application failed to start</li><li>The application started but then stopped</li><li>The application started but threw an exception during startup</li></ul>

        

        <h2> Troubleshooting steps: </h2>
        <ul>
            <li> Check the system event log for error messages </li>
            <li> Enable logging the application process' stdout messages </li>
            <li> Attach a debugger to the application process and inspect </li>
        </ul>

        <h2>
            For more information visit:
             <a href="https://go.microsoft.com/fwlink/?LinkID=2028265"> <cite> https://go.microsoft.com/fwlink/?LinkID=2028265 </cite></a>
        </h2>

    </body>

ApplicationInsights.. empty. Application logs Streaming… repeating IIS Web Server logs Streaming… useless

So, stdout can be redirected doing something in the web.config and then go into files throug kudu etc.. you can attach a debugger.. I prefer Application Insights.

Send to Application insights anyway

Create an ApplicationInsights in Azure, get it’s Instrumentation key, go to Program class, add a try-catch.

Add application insights

dotnet add package Microsoft.ApplicationInsights.AspNetCore

NOTE: This is not production code. This is just to trick azure into saying what’s going on, and then remove it.

// Program.cs
public static void Main(string[] args)
{
    TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault();
    configuration.InstrumentationKey = "applicationInsightsInstrumentationKey";
    var telemetryClient = new TelemetryClient(configuration);

    try
    {
        CreateHostBuilder(args).Build().Run();
    }
    catch (Exception ex)
    {
        telemetryClient.TrackException(ex);
    }
}

Now Application Insights/Failures, will tell on the exception.