azure-web-app-servicemonitoring

App Service Status Running with failed startup


I'm deploying an ASP.NET Core 8 Web API app with deliberately failing startup code to a Windows Azure App Service with the S1 plan. The https endpoint does return 500.30 indicating the failed startup. But the Status of the app service on the Azure Portal is "Running" which is confusing.
I would expect it to be in a failed status which does happen for Azure Functions.

Is there anything in my code/app service setup/deployment that I can change for the Status to reflect that the startup has failed?

I'm deploying via Visual Studio with the following publish profile:

Configuration: Release
Target framework: net8.0
Deployment Mode: framework-dependent
Target Runtime: Portable

Sample reproduction code: https://github.com/Aleksey-Kudryavtsev/StartupFailureAspNetCore


Solution

  • App Service Status Running with failed startup

    The status of the App service is not based on the code/any exceptions thrown.

    Is there anything in my code/app service setup/deployment that I can change for the Status to reflect that the startup has failed?

    enter image description here

    I am able to handle the exception by using the below code.

    Thanks @George for the clear steps.

    if (app.Environment.IsDevelopment())
    {    
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Home/Error");
        app.UseHsts();
    }
    app.UseStatusCodePages("text/plain", "Exception, status code: {0}");
    

    Output: enter image description here

    enter image description here