Azure Functions in Container Using App Service Plan Sleeps over Time Without Ping
Purpose
When attempting to deploy a containerized azure function (.NET 8.0 Isolated) Using the base dockerfile provided, the application will run successfully on the cloud.
This Function app has 8 service bus listeners, which are pretty consistently receiving data.
After about a 2-5~ minute interval the app will go to "sleep" and require a visit to the function app site to wake it up. This takes about 30s to 90s and does not work 100% of the time.
This obviously is not great for a service bus listener or any workload. Sending a service bus message to any topic does not wake up the app. I have also verified that the (always on) checkbox is checked.
Workaround fix
The following simple timer trigger keeps the app running
public class KeepAlive
{
private readonly ILogger _logger;
public KeepAlive(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<KeepAlive>();
}
/// <summary>
/// By Default Docker Container will stop after a few minutes of inactivity. This keeps the app alive
/// </summary>
[Function(nameof(KeepAlive))]
public void Run([TimerTrigger("*/30 * * * * *")] TimerInfo myTimer)
{
_logger.LogInformation($"Running Keep Alive on Netsuite Listener");
}
}
Suggestion
This should not be a problem on service plans that are supposed to operate constantly. This either needs to be kept awake in the background or some documentation on this should be provided.
Details
Runtime: dotnet-isolated in docker container .Net Version: 8.0 Service Plan: B1 (the app should not be sleeping)
Thanka for reporting please provide the app name,region etc
@fabiocav pls comment.
I have a Linux app service running 3 workers (background service listening on the service bus to manage queues) in Docker containers. from the logs I see that after a few seconds of warmup docker is stopped and restarts after about 30 minutes.
Container workerprod_0_b91336ac didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.` the port in the docker file is 8000 and WEBISITES_PORT is 8000. Why does this happen? Thank you