Community程式設計與開發github.com

microsoft/python-appservice-deploy

將 Python(Flask / Django / FastAPI)程式碼部署到 Azure App Service Linux。適用時機:"Flask App Service"、"Django App Service"、"FastAPI App Service"、"deploy Python to App Service"。請勿用於:Container Apps、Functions、非 Python、Terraform / Bicep / IaC、完整基礎設施 — 請改用 azure-prepare。

python-appservice-deploy 是什麼?

這個技能專門用來將 Python 應用程式(Flask、Django、FastAPI 或一般 Python)部署到 Azure App Service Linux(P0v3、Python 3.14)。它會自動建立資源群組、App Service 方案與 Web App(若缺少),並判斷應用程式框架以設定適當的啟動命令(例如 FastAPI 使用 uvicorn)。如果專案中存在 `azure.yaml`,該技能會優先使用 `azd deploy`,否則使用 `az webapp deploy` 進行 ZIP 部署。技能也強制設定了 `SCM_DO_BUILD_DURING_DEPLOYMENT=true`,並在部署完成後直接輸出後續訊息,嚴禁進行任何健康檢查或日誌追蹤,因為 App Service 需要 2–3 分鐘暖機。此外,該技能明確定義了安全規則,例如 shell 中 `--runtime` 必須使用冒號而非管線符號,且禁止使用已被棄用的 `az webapp up`。整體設計旨在提供無縫、自動化的部署體驗,並將網路、金鑰儲存庫、資料庫等基礎設施任務委派給 `azure-prepare`。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/microsoft/azure-skills/tree/main/skills/python-appservice-deploy

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Python 在 Azure App Service 上 — 程式碼部署

將 Python(Flask、Django、FastAPI、通用)程式碼部署到 Azure App Service Linux(P0v3、Python 3.14)。若資源群組、方案或 Web App 不存在則自動建立。將 VNet、Key Vault、資料庫或 IaC 相關任務交給 azure-prepare。

使用的 MCP 工具:mcp_azure_mcp_subscription_list、mcp_azure_mcp_group_list、mcp_azure_mcp_appservice、mcp_azure_mcp_azd(當存在 azure.yaml 時)。

工作流程

  1. 解析上下文 — 智慧預設值,最少提問。 只有應用程式名稱需要互動輸入;資源群組(<app>-rg)、方案(<app>-plan)、區域(目前的 az 預設值或 eastus2)、訂用帳戶都會自動推導。請參閱 create-app.md §1。
  2. 偵測框架(建議性質,絕不阻擋)。請參閱 detect.md。
  3. 選擇路徑 — azure.yaml 中 host 為 appservice → 前往 deploy-azd.md;否則前往 deploy-azcli.md。
  4. 確保資源群組 → 方案(P0v3 --is-linux)→ Web App(--runtime "PYTHON:3.14") 存在。若發生暫時性 ARM 錯誤,請遵循 transient-retry.md。請參閱 create-app.md。
  5. 設定啟動命令 — Flask/Django:無需設定(Oryx 自動偵測)。FastAPI:一律使用 python -m uvicorn main:app --host 0.0.0.0。其他框架:發出警告。請參閱 startup-commands.md。
  6. 設定 SCM_DO_BUILD_DURING_DEPLOYMENT=true。
  7. 部署 — 使用 azd deploy 或 az webapp deploy --type zip --track-status false。
  8. 停止。輸出部署後訊息(請參閱 post-deploy-message.md)並結束此回合。

嚴格規則

  • ⛔ 禁止部署後驗證 — 部署指令返回後,請勿執行 az webapp log tail、curl、Invoke-WebRequest 或任何健康狀態檢查。App Service 需要 2–3 分鐘暖機;安靜的日誌或早期的 5xx 不代表失敗。
  • ⛔ Shell 安全 — --runtime 請務必使用 "PYTHON:3.14"(冒號)。切勿使用 "PYTHON|3.14"(管線符號是 Shell 運算子)。
  • ⛔ 絕不使用 az webapp up — 已棄用。請使用步驟 7 中的指令。
  • ✅ URL 格式 — 端點一律以 https://... URL 呈現。

錯誤處理

請參閱 errors.md 以取得完整的症狀 → 原因 → 解決方案對應表。快速診斷:缺少方案或應用程式 → 重新執行步驟 4;8000 連接埠的容器 ping 逾時 → 修正啟動命令(步驟 5);部署後出現 ModuleNotFoundError → 確保步驟 6 已執行,然後重新部署。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

microsoft/airunway-aks-setup

Agent skill 'airunway-aks-setup' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/appinsights-instrumentation

Agent skill 'appinsights-instrumentation' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-ai

Agent skill 'azure-ai' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-aigateway

Agent skill 'azure-aigateway' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-app-onboard

Agent skill 'azure-app-onboard' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-app-onboard-prereq

Assess whether source code is ready to deploy to Azure — the check BEFORE infrastructure work. Evaluates build health, app completeness, dependencies and local services, stack compatibility, and deployment feasibility. Answers questions about what your app needs before it can be deployed — frameworks, dependencies, and configuration. Checks whether dependencies are compatible and identifies deployment blockers and unsupported frameworks. WHEN: \"evaluate my repo\", \"is my app ready to deploy\", \"what does my app need to deploy\", \"what do I need before deploying\", \"does my app need\", \"can I ship this to Azure\", \"scan my repo for issues\", \"is this app deployable\", \"check if my app is ready for Azure\", \"do I need a Dockerfile\", \"what's blocking my deployment\", \"are there any blockers\", \"are my dependencies compatible\", \"does Azure support my framework\", \"what needs to change before deploying\", \"check my app configuration\".

microsoft/azure-cloud-migrate

Agent skill 'azure-cloud-migrate' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-compliance

Agent skill 'azure-compliance' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-compute

Agent skill 'azure-compute' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-cost

Agent skill 'azure-cost' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-cost-optimization

Identify Azure cost savings from usage and spending data. USE FOR: optimize Azure costs, reduce Azure spending/expenses, analyze Azure costs, find cost savings, generate cost optimization report, identify orphaned resources to delete, rightsize VMs, reduce waste, optimize Redis costs, optimize storage costs, AKS cost analysis add-on, namespace cost, cost spike, anomaly, budget alert, AKS cost visibility. DO NOT USE FOR: deploying resources (use azure-deploy), general Azure diagnostics (use azure-diagnostics), security issues (use azure-security)

microsoft/azure-deploy

Agent skill 'azure-deploy' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-diagnostics

Agent skill 'azure-diagnostics' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-enterprise-infra-planner

Agent skill 'azure-enterprise-infra-planner' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-hosted-copilot-sdk

Build, deploy, and modify GitHub Copilot SDK apps on Azure. MANDATORY when codebase contains @github/copilot-sdk or CopilotClient in package.json. PREFER OVER azure-prepare when copilot-sdk markers detected. WHEN: copilot SDK, @github/copilot-sdk, copilot-powered app, build copilot app, prepare copilot app, add feature to copilot app, modify copilot app, BYOM, bring your own model, CopilotClient, createSession, sendAndWait, azd init copilot. DO NOT USE FOR: deploying already-prepared copilot-sdk apps (use azure-deploy), general web apps without copilot SDK (use azure-prepare), Copilot Extensions, Foundry agents (use microsoft-foundry).

microsoft/azure-kubernetes

Agent skill 'azure-kubernetes' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-kusto

Agent skill 'azure-kusto' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-messaging

Agent skill 'azure-messaging' from microsoft/azure-skills. Use when the task matches this skill's domain.

microsoft/azure-observability

Azure Observability Services including Azure Monitor, Application Insights, Log Analytics, Alerts, and Workbooks. Provides metrics, APM, distributed tracing, KQL queries, and interactive reports. USE FOR: Azure Monitor, Application Insights, Log Analytics, Alerts, Workbooks, metrics, APM, distributed tracing, KQL queries, interactive reports, observability, monitoring dashboards. DO NOT USE FOR: instrumenting apps with App Insights SDK (use appinsights-instrumentation), querying Kusto/ADX clusters (use azure-kusto), cost analysis (use azure-cost-optimization).

microsoft/azure-postgres

azure-postgres — an installable skill for AI agents.

相關技能