App Service frequent recycling — Always On disabled or scale-out thrash
App recycles every few minutes with no code change
Focused incident mode — strips away everything but this runbook.
Symptoms
- App recycles every few minutes with no code change
- HTTP 503 intermittent, especially after idle
- Worker process restarts with no OOM in the logs
Always On is unavailable on Free and Basic tiers. If your app recycles every few minutes, the first check should always be the tier and Always On setting.
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
Always On setting
az webapp config show --name <APP> --resource-group <RG> --query alwaysOn -o tsvApp Service plan tier
az appservice plan show --name <PLAN> --resource-group <RG> --query "{tier:sku.tier,capacity:sku.capacity}" -o json
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- az webapp config show returns alwaysOn = false
- Recycle happens after idle period, not under load
Confirm before fixing
az webapp config show --name <APP> --resource-group <RG> --query alwaysOn -o tsvConfirm Always On setting
Fix
az webapp config set --name <APP> --resource-group <RG> --always-on trueEnable Always On (requires Standard tier+)
Expected: Successfully updated App Service settings
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
az webapp config show --name <APP> --resource-group <RG> --query alwaysOn -o tsvCheck Always On status
az appservice plan show --name <PLAN> --resource-group <RG> --query "{tier:sku.tier,capacity:sku.capacity}" -o jsonReview the plan tier
az webapp config set --name <APP> --resource-group <RG> --always-on trueEnable Always On
az appservice plan update --name <PLAN> --resource-group <RG> --sku S1Upgrade to Standard tier if currently Free or Basic
Prevention
- Enable Always On on all production App Service plans.
- Use Standard tier or higher for production workloads.
- Set autoscale rules with a 5-minute cooldown to prevent thrashing.
- Monitor CurrentInstanceCount and HttpQueueLength for scale stability.
Related runbooks
Same stack, same failure family — worth a skim.
HTTP 503 returned on the default .azurewebsites.net domain
az webapp deployment slot swap returns a conflict error
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.