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"。不适用于:容器应用、函数应用、非 Python 应用、Terraform/Bicep/IaC、完整基础设施——请使用 azure-prepare。

python-appservice-deploy 是什么?

本技能用于将 Python Web 应用(Flask、Django、FastAPI 或通用 Python 项目)部署到 Azure App Service Linux(P0v3 层,Python 3.14 运行时)。它能自动创建资源组、App Service 计划和 Web 应用(若尚不存在),并处理启动命令配置和环境变量设置。该技能支持两种部署路径:当项目包含 `azure.yaml` 文件时优先使用 `azd deploy`,否则使用 `az webapp deploy --type zip`。它通过一系列 MCP 工具与 Azure 交互,包括订阅列表、资源组列表、应用服务管理和 azd 集成。关键限制包括:禁止部署后验证(App Service 需要 2-3 分钟预热)、禁止使用已弃用的 `az webapp up` 命令、以及 shell 安全规则(runtime 参数必须使用冒号而非管道符)。

兼容平台~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)。如果资源组、App Service 计划或 Web 应用不存在,则自动创建。需要 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 应用(--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.

相关技能