Azure Functions in Container Using App Service Plan Sleeps over Time Without Ping
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 215
- Avg merge
- 4h 2m
- Merged PRs (30d)
- 1
Description
## 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
```CSharp
public class KeepAlive
{
private readonly ILogger _logger;
public KeepAlive(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger();
}
///
/// By Default Docker Container will stop after a few minutes of inactivity. This keeps the app alive
///
[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)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.