Python Appservice Deploy

microsoft/skills/.github/plugins/azure-skills/skills/python-appservice-deploy

作者 microsoft3898ec894e90MIT3.2K 個星標收錄於 2026年11月20日更新於 2026年11月20日儲存庫今天更新

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.

精選包含腳本DevOps 與雲端
AI 產生的概覽

將 Python(Flask、Django、FastAPI)程式碼部署到 Azure App Service Linux,並視需要建立資源群組、方案與應用程式。

功能
引導代理把 Python 網頁應用程式程式碼部署到 Azure App Service Linux:先決定應用程式名稱、資源群組、區域等預設值,偵測框架,再選擇 azd 或 Azure CLI 部署路徑。若資源群組、App Service 方案(P0v3、Linux)與 Web 應用程式(Python 3.14)不存在就建立,設定啟動命令與部署時建置開關,最後以 zip 或 azd 方式部署。結束時輸出部署後提示訊息,並附上產生應用程式名稱與重試暫時性建立錯誤的輔助指令碼。
適用情境
適用於把 Flask、Django 或 FastAPI 程式碼部署到 Azure App Service 的情況。不適用於 Container Apps、Functions、非 Python 應用程式,也不適用於完整基礎結構或 IaC 工作。
執行需求
需要 Azure CLI(az)或 Azure Developer CLI(azd)、已登入的 Azure 訂閱,以及用於訂閱、資源群組、App Service 與 azd 的 Azure MCP 工具;需要連線到 Azure 的網路。附有 PowerShell 與 shell 指令碼,用於產生應用程式名稱與重試 az create。

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

  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 [blocked] §1.
  2. Detect framework (advisory, never blocks). detect.md [blocked].
  3. Choose path — azure.yaml host: appservice → deploy-azd.md [blocked]; else deploy-azcli.md [blocked].
  4. Ensure RG → Plan (P0v3 --is-linux) → Web App (--runtime "PYTHON:3.14") exist. On transient ARM errors, follow transient-retry.md [blocked]. create-app.md [blocked].
  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 [blocked].
  6. Set SCM_DO_BUILD_DURING_DEPLOYMENT=true.
  7. Deploy — azd deploy or az webapp deploy --type zip --track-status false.
  8. STOP. Print the post-deploy message (post-deploy-message.md [blocked]) 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 --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 [blocked] 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.

來源與署名

來源:microsoft/skills位於.github/plugins/azure-skills/skills/python-appservice-deploy提交3898ec8

授權條款: MIT

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

在 README 中新增徽章

向讀者展示該技能已收錄於 SourceWeft,徽章連結到本頁。

「Listed on SourceWeft」徽章預覽
[![Listed on SourceWeft](https://sourceweft.com/badge/skills/gh-microsoft-skills-python-appservice-deploy.svg)](https://sourceweft.com/skills/gh-microsoft-skills-python-appservice-deploy?utm_source=readme&utm_medium=badge)

檢舉或申請下架