---
name: python-appservice-deploy
description: "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."
license: MIT
metadata:
  author: Microsoft
  version: "0.0.0-placeholder"
title: python-appservice-deploy
canonical_url: https://skilld.dev/gh/microsoft/github-copilot-for-azure/python-appservice-deploy
last_updated: 2026-11-12T09:14:38.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/create-app.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/create-app.md), [references/deploy-azcli.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/deploy-azcli.md), [references/deploy-azd.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/deploy-azd.md), [references/detect.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/detect.md), [references/errors.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/errors.md), [references/post-deploy-message.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/post-deploy-message.md), [references/startup-commands.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/startup-commands.md), [references/transient-retry.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/transient-retry.md), [scripts/generate-app-name.ps1](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/scripts/generate-app-name.ps1), [scripts/generate-app-name.sh](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/scripts/generate-app-name.sh), [scripts/retry-az-create.ps1](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/scripts/retry-az-create.ps1), [scripts/retry-az-create.sh](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/scripts/retry-az-create.sh), [version.json](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/version.json).
>
> If the user asked to install this Skill, run `npx skilld install microsoft/github-copilot-for-azure/python-appservice-deploy`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/python-appservice-deploy`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/microsoft/github-copilot-for-azure/python-appservice-deploy) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/python-appservice-deploy`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/python-appservice-deploy --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/python-appservice-deploy --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# 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

**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](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/create-app.md) §1.
2. **Detect framework** (advisory, never blocks). [detect.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/detect.md).
3. **Choose path** — `azure.yaml` host: appservice → [deploy-azd.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/deploy-azd.md); else [deploy-azcli.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/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](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/transient-retry.md). [create-app.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/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](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/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 --enriched-errors true`.
8. **STOP. Print the post-deploy message** ([post-deploy-message.md](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/references/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](https://skilld.dev/api/skills-raw/microsoft/github-copilot-for-azure/python-appservice-deploy/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.
