Troubleshoot unwanted Azure App Service app unloads

2026-10-20T10:48:54.5566667+00:00

I run a bunch of applications from Docker containers on Azure App Service. All applications expose a health check endpoint that reports healthy. All apps are also configured for 'always on'. There's only one instance, because they're not really business critical.

Anyway.. so I've noted that despite the health check, one of my apps seems to go down over the night - I see the usual container startup messages in the log stream. So, the container was stopped before. I know nobody manually stopped it, and looking at the restarts, I see a restart when the app was started again in the morning.

Also, it seems the app didn't undergo a normal shutdown. I register my own handle for IHostApplicationLifetimeand the OnShutdown should trigger some cleanup that never gets made and that causes issues on startup (the app uses LiteDB database and should Checkpoint the database).

So.. I'd like to find out..

  • Why does my app get stopped.
  • Why does my app get stopped.
  • And why isn't the app stopped properly?
Azure
Azure

A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-10-20T10:49:19.9133333+00:00

    What is visible from the documented behavior is:

    1. An App Service app can consume resources and run platform processes even when no app workload is active. App Service keeps platform processes running for security updates, SCM/Kudu availability, monitoring, authentication, and other platform features. That means app lifecycle events are not driven only by application traffic.
    2. A container restart or stop can be platform-initiated even when the app appears healthy. Accepted Microsoft Q&A guidance for similar App Service container scenarios calls out these common causes:
      • Auto-Heal rules restarting the app/container.
      • Platform maintenance, container image refresh, or proactive platform management causing silent restarts.
      • Health check failures, including brief failures, latency, or missed expected responses, causing the platform to restart the app.
    3. Health check and site status are different signals. Health check only pings the configured endpoint and uses its HTTP response to decide whether an instance should receive traffic. Site status reports the platform-defined runtime state of the app and is intended to help explain startup, runtime, and configuration issues. A healthy health endpoint does not by itself prove that no platform restart occurred.

    For investigation, use this path:

    1. In the Azure portal, open the App Service.
    2. Go to Diagnose and solve problems.
    3. Check Availability and Performance diagnostics.
    4. Review:
      • Auto-Heal to see whether any custom or triggered healing rules restarted the app.
      • Web App Restarted to review restart history.
    5. Check the site status page to understand the platform-reported runtime state and any detailed error information.
    6. If the site status indicates an issue and self-service diagnostics do not explain it, open a support request.

    For reducing recurrence:

    1. Keep Always On enabled, which helps reduce cold starts after idle time.
    2. Configure a reliable Health check path so App Service can detect and replace unresponsive instances.
    3. Account for baseline platform resource usage in monitoring and autoscale thresholds, because App Service plans use some CPU and memory for platform processes even when apps are stopped.

    On the question of why shutdown cleanup did not run properly: the provided material supports that App Service can stop or restart containers due to platform actions, health checks, Auto-Heal, or maintenance, but it does not document the shutdown semantics for IHostApplicationLifetime or guarantee that an app-level shutdown handler will run in every stop scenario. Only the supported conclusion is that some restarts can occur outside a normal application-controlled shutdown path.


    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.