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. 1.Enable Always On (requires Standard tier or higher):
  2. 2.```bash
  3. 3.az webapp config set --resource-group my-rg --name my-app --always-on true
  4. 4.`
  5. 5.Configure application initialization warm-up (for .NET apps in web.config):
  6. 6.```xml
  7. 7.<system.webServer>
  8. 8.<applicationInitialization doAppInitAfterRestart="true">
  9. 9.<add initializationPage="/warmup" />
  10. 10.<add initializationPage="/api/health" />
  11. 11.</applicationInitialization>
  12. 12.</system.webServer>
  13. 13.`
  14. 14.Add a warm-up endpoint to your application:
  15. 15.```csharp
  16. 16.[HttpGet("warmup")]
  17. 17.public IActionResult Warmup() {
  18. 18._cache.Initialize();
  19. 19._dbContext.Database.CanConnect();
  20. 20.return Ok("warm");
  21. 21.}
  22. 22.`
  23. 23.Verify with continuous requests:
  24. 24.```bash
  25. 25.for i in {1..12}; do
  26. 26.curl -s -o /dev/null -w "Request $i: HTTP %{http_code} (%{time_total}s)\n" \
  27. 27.https://my-app.azurewebsites.net/api/health
  28. 28.sleep 300
  29. 29.done
  30. 30.`

Prevention - Always enable Always On for production App Services - Use Premium v3 tier for guaranteed compute with Always On included - Configure Azure Monitor health check alerts - Set WEBSITE_RUN_FROM_PACKAGE for faster cold starts - Use Azure Container Apps as alternative with always-on behavior by default