Debugging Azure App Service 500.30 startup failures with Application Insights
Goal
Capture and diagnose silent startup failures in Azure App Service that only show HTTP Error 500.30 - ANCM In-Process Start Failure.
The Problem
Azure App Service fails with a generic IIS error page that provides no actionable information:
<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>
Standard Azure diagnostics won’t help:
- ApplicationInsights: empty
- Application logs streaming: repeats IIS error
- Web server logs: useless
Solution
Force exception logging to Application Insights before the host crashes.
Install the Application Insights package:
dotnet add package Microsoft.ApplicationInsights.AspNetCore
Wrap host startup in a try-catch that sends exceptions directly to Application Insights:
// 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);
}
}
Note: This is diagnostic code only. Remove after identifying the issue.
Check Application Insights > Failures for the actual exception details.