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.