Azure Web App Container Unhealthy With No Resolution

Nicolas Joye 0 Reputation points
2025-03-12T17:33:47.1933333+00:00

We have a fastapi application running in azure hooked up to a azure sql instance running in the deploy as code version of azure web apps. Everything is working fine accept sometimes there is a hang up on once of the instances that doesn't correct itself. There is no errors in any of the logs we can find. It seems to be happing post sending call to database but we are not sure. The only indication we have is that the app instance is unhealthy and we are forced to restart. This will not provide a ideal user experience if users are sending requests. Please advise.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,931 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bhargavi Naragani 5,270 Reputation points Microsoft External Staff Moderator
    2025-03-12T22:38:56.6333333+00:00

    Hi @Nicolas Joye,

    It seems like you’re running into an intermittent issue with your FastAPI application where one of the Azure Web App instances becomes unhealthy and doesn’t recover on its own, even though there are no errors in the logs. Since this happens after sending a call to the Azure SQL database, the issue could be related to long-running queries, connection handling, or container-level health checks.

    Make sure that the health check endpoint is configured correctly, and the endpoint itself responds quickly. In case the health check times out or hangs on a database call, the instance would be classified as unhealthy.

    Check your FastAPI application is handling database connections efficiently. Unclosed or long-running connections might cause hangs.

    If you have not already, configure Application Insights to capture comprehensive telemetry and performance information. You will be able to monitor slow requests, failing dependencies, and any potential bottlenecks. You can also configure auto-healing rules such that an unhealthy instance will restart automatically without intervention.

    If the problem occurs under load, scaling out (adding more instances) may help load balance the traffic. Since the issue appears to occur after calling the database, look at long-running queries and try adding indexes or optimizing your database queries.

    Monitor instance health
    Application Insights overview
    Scale an App Service plan
    Automatic performance monitoring and tuning

    If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.

    Let me know if you have any further Queries.


Your answer

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