Introduction Azure App Service unloads applications after 20 minutes of inactivity by default. Without Always On enabled, the next request triggers a cold start, causing a 503 Service Unavailable response while the application initializes. This is especially problematic for APIs, webhooks, and background job processors.
Symptoms - First request after idle period returns 503 or takes 30+ seconds - Subsequent requests work normally - Kudu console shows application domain unloaded/recycled - Application Insights shows cold start gaps in request timeline - Webhook endpoints missing deliveries during idle periods
Common Causes - Always On setting disabled (default on Basic/Standard tiers) - Free/Shared tier does not support Always On - App pool recycling due to memory limits or configuration changes - Application initialization module not configured for warm-up
Step-by-Step Fix 1. **Check current Always On setting**: ```bash az webapp config show --resource-group my-rg --name my-app --query alwaysOn ```
- 1.Enable Always On (requires Standard tier or higher):
- 2.```bash
- 3.az webapp config set --resource-group my-rg --name my-app --always-on true
- 4.
` - 5.Configure application initialization warm-up (for .NET apps in web.config):
- 6.```xml
- 7.<system.webServer>
- 8.<applicationInitialization doAppInitAfterRestart="true">
- 9.<add initializationPage="/warmup" />
- 10.<add initializationPage="/api/health" />
- 11.</applicationInitialization>
- 12.</system.webServer>
- 13.
` - 14.Add a warm-up endpoint to your application:
- 15.```csharp
- 16.[HttpGet("warmup")]
- 17.public IActionResult Warmup() {
- 18._cache.Initialize();
- 19._dbContext.Database.CanConnect();
- 20.return Ok("warm");
- 21.}
- 22.
` - 23.Verify with continuous requests:
- 24.```bash
- 25.for i in {1..12}; do
- 26.curl -s -o /dev/null -w "Request $i: HTTP %{http_code} (%{time_total}s)\n" \
- 27.https://my-app.azurewebsites.net/api/health
- 28.sleep 300
- 29.done
- 30.
`