Python on Azure App Service โ Code Deploy
Deploys Python (Flask, Django, FastAPI, generic) code to Azure App Service Linux (P0v3, Python 3.14). Creates RG + Plan + Web App if missing. Hand off to azure-prepare for VNet, Key Vault, databases, or IaC.
MCP tools used: mcp_azure_mcp_subscription_list, mcp_azure_mcp_group_list, mcp_azure_mcp_appservice, mcp_azure_mcp_azd (when azure.yaml is present).
Workflow
- Resolve context โ smart defaults, minimal prompts. Only the app name is interactive; RG (
<app>-rg), Plan (<app>-plan), region (currentazdefault oreastus2), subscription are derived. create-app.md ยง1. - Detect framework (advisory, never blocks). detect.md.
- Choose path โ
azure.yamlhost: appservice โ deploy-azd.md; else deploy-azcli.md. - Ensure RG โ Plan (
P0v3 --is-linux) โ Web App (--runtime "PYTHON:3.14") exist. On transient ARM errors, follow transient-retry.md. create-app.md. - Set startup โ Flask/Django: none (Oryx auto-detects). FastAPI: always
python -m uvicorn main:app --host 0.0.0.0. Other: warn. startup-commands.md. - Set
SCM_DO_BUILD_DURING_DEPLOYMENT=true. - Deploy โ
azd deployoraz webapp deploy --type zip --track-status false. - STOP. Print the post-deploy message (post-deploy-message.md) and end the turn.
Hard rules
- โ NO POST-DEPLOY VERIFICATION โ after deploy returns, do not run
az webapp log tail,curl,Invoke-WebRequest, or any health probe. App Service needs 2โ3 min to warm; a quiet log or early 5xx is not failure. - โ SHELL SAFETY โ for
--runtimealways use"PYTHON:3.14"(colon). Never"PYTHON|3.14"(pipe is a shell operator). - โ NEVER
az webapp upโ deprecated. Use Step 7 commands. - โ
URL FORMAT โ present endpoints as
https://...URLs.
Error Handling
See errors.md for the full symptom โ cause โ fix matrix. Quick triage: missing plan/app โ re-run Step 4; container ping timeout on 8000 โ fix startup (Step 5); ModuleNotFoundError after deploy โ ensure Step 6 ran, redeploy.