Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Azure Functions in Container Using App Service Plan Sleeps over Time Without Ping

Open Pieeer1 opened this issue 1 year ago • 3 comments

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)

Pieeer1 avatar Apr 12 '24 15:04 Pieeer1

Thanka for reporting please provide the app name,region etc

bhagyshricompany avatar Apr 15 '24 04:04 bhagyshricompany

@fabiocav pls comment.

bhagyshricompany avatar Apr 16 '24 11:04 bhagyshricompany

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

Vice95 avatar Jun 13 '24 12:06 Vice95