---
id: gh-python-appservice-deploy
name: "python-appservice-deploy"
url: https://skills.yangsir.net/skill/gh-python-appservice-deploy
author: microsoft
domain: ai-ci-cd-deployment
tags: ["python", "azure", "app-service", "deployment", "web-app"]
install_count: 227300
rating: 4.80 (120 reviews)
github: https://github.com/microsoft/azure-skills/tree/main/.github/plugins/azure-skills/skills/python-appservice-deploy
---

# python-appservice-deploy

> 此技能用于将 Python (Flask/Django/FastAPI) 应用程序部署到 Azure App Service Linux。它能自动创建所需的资源组、应用服务计划和 Web 应用，并配置运行时环境，简化了 Python 应用在 Azure 上的部署流程，确保快速上线和稳定运行。

**Stats**: 227,300 installs · 4.8/5 (120 reviews)

## Before / After 对比

### Python 应用部署效率

**Before**:

在没有此技能之前，用户需要手动配置 Azure 资源，包括创建资源组、应用服务计划和 Web 应用，并手动处理 Python 运行时和依赖配置，整个过程耗时且容易出错。

**After**:

该 Skill 自动化了 Azure 资源的创建和 Python 应用的部署流程，用户只需提供少量信息即可快速完成部署，显著减少了手动操作和潜在错误，提升了开发效率。

| Metric | Before | After | Change |
|---|---|---|---|
| 部署时间 | 45分钟 | 5分钟 | -89% |

## Readme

# 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](references/create-app.md) §1.
2. **Detect framework** (advisory, never blocks). [detect.md](references/detect.md).
3. **Choose path** — `azure.yaml` host: appservice → [deploy-azd.md](references/deploy-azd.md); else [deploy-azcli.md](references/deploy-azcli.md).
4. **Ensure RG → Plan (`P0v3 --is-linux`) → Web App (`--runtime "PYTHON:3.14"`)** exist. On transient ARM errors, follow [transient-retry.md](references/transient-retry.md). [create-app.md](references/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](references/startup-commands.md).
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](references/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 `--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](references/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.


---
*Source: https://skills.yangsir.net/skill/gh-python-appservice-deploy*
*Markdown mirror: https://skills.yangsir.net/api/skill/gh-python-appservice-deploy/markdown*