Azure App Service container keeps restarting - "Container failed availability check."

Viewed 2244

Sorry, I can't provide you a reproducible example but I hope you can help me to figure out what's going wrong in my environment.

I run a windows container based .NET 4.7 application inside a PC3 App Service Plan (16GB RAM). The application exposes a REST API and is also a JobHost that gets triggered on certain BlobStorage Events.

The whole business logic works fine - it runs without any issues locally and it does also run a limit time (1 - 5 min) on Azure. However, somehow the container gets restarted every x minutes and I am not able to figure out why.

This is what I see in the container logs:

02/10/2019 12:23:46.142 INFO - Site: myapp - Container failed availability check. It has failed 122895 check(s). Container will be declared unavailable if it exceeds 3 consecutive failed checks.
02/10/2019 12:23:46.142 ERROR - Site: myapp - Container is unavailable.
02/10/2019 12:23:47.129 INFO - Site: myapp - Container failed availability check. It has failed 5 check(s). Container will be declared unavailable if it exceeds 3 consecutive failed checks.
02/10/2019 12:23:47.129 ERROR - Site: myapp - Container is unavailable.
....
02/10/2019 12:23:56.862 INFO - Site: myapp - Attempting to stop container: 310a7f2278cdb56...
02/10/2019 12:23:56.895 INFO - Site: myapp - Purging pending logs after stopping container
02/10/2019 12:23:56.895 INFO - Site: myapp - Container stopped successfully. Container Id: 310a7f2278cdb56....

I have no idea why the availability check fails. Can someone explain to me how the check works and how I can get further information on why it fails?

1 Answers

The App Service platform periodically checks for your container's availability by trying to reach the container on it's http endpoint. If the container doesn't respond, or takes more than 5 seconds to respond, we assume the availability check failed. If there are three consecutive failures we assume the container is unhealthy, stop it and start again.

If your application is memory/resource intensive it is likely that the container might not be able to respond within these parameters.

We introduced some application settings which you can set on your app which will enable you to control the actions when availability checks fail:

CONTAINER_AVAILABILITY_CHECK_MODE=Repair

The platform checks for availability and stops and restart the container after 3 consecutive availability checks (default)

CONTAINER_AVAILABILITY_CHECK_MODE=ReportOnly

The platform checks for availability and reports (in the logs) the container after 3 consecutive availability checks (default). The platform doesn’t stop/restart the container

CONTAINER_AVAILABILITY_CHECK_MODE=Off

The platform doesn’t check for availability

We also have a Windows Containers on App Service wiki for items which you may find useful which haven't been incorporated into our documentation so far.

Related