How can I stop my Azure App Services from randomly restarting?

June 3, 2025 5 answers
Asked by _206 bones to learn
I'm currently managing several Azure App Services that maintain long-lived WebSocket connections. Lately, I've noticed that these services restart unexpectedly, which I suspect might be due to Azure's container updates. I found that setting CI_DOCKER_ENABLED to false helps reduce the frequency of these restarts, but they still happen on occasion, which is frustrating. Is there a way to prevent Azure from interfering with my container setup and these random restarts?

Answers

403 missing page
Have you checked if something like an out-of-memory (OOM) issue is triggering the restarts? It's also possible that Azure is maintaining the underlying hosts. Since you're using a managed service, some control is out of your hands. The best practice is to design your app to be stateless or switch to a platform where you have more control.
Reply to this answer
first-past-the-post
Are you using heartbeats to keep your WebSocket connections alive? In my experience with container app environments, we have several long-lived connections, and we rarely encounter restarts.
Reply to this answer
irq12!masked
You can't fully prevent the restarts, but timing them with a maintenance window can help. You should also keep in mind that hardware failures will still happen regardless. Consider making your application more resilient to these kinds of issues.
Reply to this answer
crustScore-V2
Unfortunately, you can't completely avoid restarts. The more premium workload profiles allow you to set a maintenance window, which might help manage when restarts occur. That's your best shot at minimizing disruptions.
Reply to this answer
Jollity
It's essential to prepare for the possibility of disconnections and restarts. Your application should ideally detect these events and quickly attempt to reconnect. This is particularly crucial for services where downtime can impact users, like trading.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions