Skip to content

About

Dependency-free Python learning sample for App Service Builder, with a responsive visual showcase.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

App Service Builder Python sample

A minimal Python 3.14 HTTP app for learning how to deploy a GitHub repository with App Service Builder (Private Preview). It uses only the Python standard library: no framework, third-party packages, container files, or other repository is required.

This is a dev/test learning sample, not a production HTTP server. Live end-to-end preview qualification is pending; local checks do not prove a successful cloud build or deployment.

Preview

The visual showcase is served directly at /, without a redirect.

Python root greeting with the official language logo, Builder context and inline health check

Real local rendering in Microsoft Edge, not evidence of an Azure deployment. Check app health displays server liveness on this page without navigating to the plain-text response. /health remains unchanged. The page explains how to customize SAMPLE_GREETING in your own Builder App and deploy the change.

Features

  • / returns HTTP 200 and text/html; charset=utf-8, displaying the public greeting.
  • /health returns HTTP 200 and OK; unknown paths return HTTP 404.
  • / is a responsive, dependency-free visual introduction with the current public greeting, Python language identity, customization guidance, and links to the real routes. /health retains its plain-text response.
  • SAMPLE_GREETING changes the deliberately public greeting.
  • Root-level builder.yaml explicitly selects Python 3.14, the startup command python app.py, and /health. It relies on the single-component defaults for the root path (/), port 8080, and the required HTTP 200 health response.
  • Dependency-free HTTP tests run locally and in GitHub Actions.

Getting Started

Prerequisites

  • Python 3.14, available as python3 (or python on Windows).
  • Git, plus curl or a browser for HTTP checks.
  • For deployment: Private Preview access, an authorized Azure subscription and resource group, and GitHub access to your own fork. Use a location available to your preview subscription; this sample does not assume a region.

Installation

Fork this repository to your own GitHub account. Clone your fork, replacing <your-github-account>:

git clone https://github.com/<your-github-account>/app-service-builder-python.git
cd app-service-builder-python
python3 --version

No package installation is required. requirements.txt intentionally contains no packages, but must remain at the repository root as the build dependency manifest. Optionally create a virtual environment:

python3 -m venv .venv
. .venv/bin/activate

On Windows PowerShell use Python 3.14 as python, create the environment with python -m venv .venv, and activate it with .venv\Scripts\Activate.ps1.

Quickstart

From the repository root:

python3 app.py

The server binds to 0.0.0.0:8080, so it can also be reached from your local network. Use it only in a trusted dev/test environment. In another terminal:

curl -i http://localhost:8080/
curl -i http://localhost:8080/health
curl -i http://localhost:8080/not-found

Expect HTTP 200 with HTML displaying Hello, HTTP 200 with OK, and HTTP 404 with Not found, respectively. Stop the server with Ctrl+C. Do not override PORT: this sample always listens on 8080.

Open http://localhost:8080/ in a browser for the visual showcase. It uses local inline styles and system fonts; no external assets or package installation is needed; inline JavaScript checks health. SAMPLE_GREETING is displayed as escaped text on this page. Keep demo.html alongside app.py; the server loads it relative to the script, not the current working directory.

Demo

Deploy your fork with Portal

Follow the Portal quickstart using your Private Preview access:

  1. Sign in to Portal and select your authorized subscription and resource group. Create an app in a location available to your preview.
  2. Authorize the GitHub source connection for your fork. If your organization restricts repository access, have an authorized owner grant access to that repository. Do not select the upstream AzureAppService repository.
  3. Select your fork's main branch and the repository root as the app source root. Keep app.py, requirements.txt, and builder.yaml together at that root, along with demo.html; there is no samples/python-web subdirectory to select.
  4. Start deployment and wait for a successful terminal deployment state. Submitting a deployment request does not mean it has finished.
  5. Read the app's runtime URL from Portal, then check both / and /health:
curl -i "https://<runtime-host>/"
curl -i "https://<runtime-host>/health"

Both must return HTTP 200 and the expected greeting/OK bodies. If deployment fails or the health check fails, inspect the deployment status and logs before proceeding. These are instructions, not evidence of a completed cloud deployment.

Change the greeting

For a local demo, stop the existing server and restart it:

SAMPLE_GREETING="Welcome" python3 app.py

On Windows PowerShell set $env:SAMPLE_GREETING = "Welcome" and run python app.py. The root HTML displays Welcome. An unset or empty value uses Hello. Never put secrets or personal data in this setting: the value is returned publicly over HTTP.

In Portal Variables, set SAMPLE_GREETING and choose Save and deploy. Save only changes desired configuration, not existing runtime processes: explicitly deploy afterward. Wait for completion and check / again. Activating a retained version uses that version's historical values. See the variables guide.

Push an app change and explicitly redeploy

After editing your fork locally:

git add app.py
git commit -m "Update sample greeting"
git push origin main

Push the files you actually changed to the branch connected in Portal. Builds read committed GitHub source, not your local working tree. A push alone is not a promise of automatic deployment: explicitly deploy the connected main branch in Portal, wait for completion, and verify / and /health again.

Cleanup

Stop local Python with Ctrl+C and run deactivate if you activated a virtual environment. In Portal, delete only the sample app and wait for deletion to complete. Do not delete the resource group or subscription: they may contain unrelated resources. App deletion does not delete your GitHub fork or separately created Azure resources.

Validation

Run from the repository root with Python 3.14:

python3 -m py_compile app.py
python3 -m unittest discover -s tests -v

On Windows use python instead of python3. Tests start owned servers on ephemeral loopback ports, check root HTML, health text, public greetings, HTML escaping, query strings, 404s (including the removed showcase route), and unsupported methods returning 501, and shut down afterward. They do not deploy to Azure or require credentials.

The build contract remains Python 3.14, python app.py, port 8080, and /health returning exactly HTTP 200. The manifest pins the runtime, startup command, and health path; the root path (/), port 8080, and exact HTTP 200 health status use the single-component defaults. There is no custom build or output path and no Flask/Django/WSGI detection requirement. Keep the root manifest and the empty dependency manifest intact when experimenting. Preview build-image/runtime support still requires end-to-end qualification.

Resources

Contributing and security

See CONTRIBUTING.md, the Microsoft Open Source Code of Conduct, and the MIT license. For security vulnerabilities, follow Microsoft's security reporting guidance rather than opening a public issue.

The product mark uses the supplied App Service Builder asset in assets/AppServiceBuilder.svg. Its SVG is inlined in the root page to preserve the existing routes and security policy. Keep the inline copy and asset in sync when updating the logo.

Language identity

The page uses the official Python logo and links separately to Python documentation and Builder documentation. The greeting remains simple; no editor or counter was added. Logo provenance and trademark notices are available on the page and the original asset is retained under assets/.

About

Dependency-free Python learning sample for App Service Builder, with a responsive visual showcase.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages