Chapter 37 · Python Appservice Deploy
Subchapter 37.8
references/transient-retry.mdMarkdown2 KBView on GitHub
az ... createLoad this file only when an az group create, az appservice plan create, or az webapp create command fails. Healthy runs never need it.
ARM PUT operations sometimes fail with transient errors:
Connection reset, Connection aborted, ConnectionErrorRead timed out, Max retries exceededBadGatewayConnection, ServiceUnavailableTooManyRequests / HTTP 429502 / 503 / 504These are ARM frontend / network blips, not configuration problems — they almost always succeed on retry.
Do NOT retry on AuthorizationFailed, SubscriptionNotFound, ResourceGroupNotFound, InvalidTemplateDeployment, SkuNotAvailable, QuotaExceeded, or any non-429 4xx. Those are real config errors — surface them to the user.
az ... create in create-app.md §§2–4.Retry-After header, honour that instead.(az ... show ...) || (az ... create ...) — never the bare create. The show short-circuits any partially-succeeded prior attempt and avoids false Conflict / NameAlreadyExists."ARM frontend is returning transient errors — please retry in a few minutes").Both shells have a ready-to-call wrapper that implements the loop, the transient-error filter, and the backoff. Prefer these over inlining the loop:
scripts/retry-az-create.sh
./scripts/retry-az-create.sh \
"az group show -n my-rg --only-show-errors" \
"az group create -n my-rg -l eastus2"scripts/retry-az-create.ps1
.\scripts\retry-az-create.ps1 `
-ShowCommand "az group show -n my-rg --only-show-errors" `
-CreateCommand "az group create -n my-rg -l eastus2"Both scripts run the show command first, fall through to create on failure, and retry up to 2 times on transient errors only.