技能低风险未认领

Python on Azure App Service — Code Deploy

Deploy Python (Flask/Django/FastAPI) code to Azure App Service Linux. WHEN: "Flask App Service", "Django App Service", "FastAPI App Service", "deploy Python to App Service". DO NOT USE FOR: Container Apps, Functions, non-Python, Terraform/Bicep/IaC, full infra — use azure-prepare.

microsoftmicrosoft/python-appservice-deploy★ 3.2k更新于 2026年11月12日

说明

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

Prerequisite: Verify the latest stable Azure CLI; update with approval and recheck if needed.

  1. Resolve context — smart defaults, minimal prompts. Only the app name is interactive; RG (<app>-rg), Plan (<app>-plan), region (current az default or eastus2), subscription are derived. create-app.md §1.
  2. Detect framework (advisory, never blocks). detect.md.
  3. Choose path — azure.yaml host: appservice → deploy-azd.md; else deploy-azcli.md.
  4. Ensure RG → Plan (P0v3 --is-linux) → Web App (--runtime "PYTHON:3.14") exist. Before creating a plan, invoke azure-quotas to check quota availability. On transient ARM errors, follow transient-retry.md. create-app.md.
  5. 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.
  6. Set SCM_DO_BUILD_DURING_DEPLOYMENT=true.
  7. Deploy — azd deploy or az webapp deploy --type zip --track-status false --enriched-errors true.
  8. STOP. Print the post-deploy message (post-deploy-message.md) and end the turn.

Hard rules

  • LINUX SCRIPTS — normalize selected shell/startup files to LF, then verify no CR bytes remain. Stop on normalization, validation or packaging failure; deploy only a fresh package.
  • DJANGO REMOTE BUILDS — require STATIC_ROOT and successful system/collectstatic checks before packaging.
  • ⛔ 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 --runtime always 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.

权限

声明检测
运行代码—powershellshell
安装—pip
安装时运行脚本—无
网络—learn.microsoft.com
需要的凭据—无
工作区外的路径—无
智能体工具—无

检查

低风险 · 没有发现需要提醒的地方。

未经人工审核 · 已做规则检查;模型审核尚未开启。

另有 3 处低风险标记:常见命令之类,只记录、不提醒
  • 规则 · command_injectionreferences/deploy-azcli.md:88
  • 规则 · command_injectionreferences/deploy-azcli.md:89
  • 规则 · command_injectionreferences/deploy-azcli.md:97

文件13 个文件 · 45.5 KB

  • SKILL.md3.2 KB
references/8
  • create-app.md6.2 KB
  • deploy-azcli.md6.8 KB
  • deploy-azd.md3.4 KB
  • detect.md3.6 KB
  • errors.md3.8 KB
  • post-deploy-message.md4.4 KB
  • startup-commands.md4.3 KB
  • transient-retry.md2.3 KB
scripts/4
  • generate-app-name.ps11.7 KB
  • generate-app-name.shx1.8 KB
  • retry-az-create.ps12.1 KB
  • retry-az-create.shx1.9 KB

版本

  1. #31.1.3最新2026年11月12日
  2. #21.1.22026年11月6日
  3. #11.1.12026年10月6日

在 Codeg 中打开

也可以复制地址,在 Codeg 的「发现」里搜索。

microsoft/python-appservice-deploy

还没有 Codeg?下载