All Posts
2025-03-09

Hosting a Flask App on Azure App Service

Overview

This guide walks through deploying a Python Flask app to Azure App Service — from creating the resource to pointing your custom domain at it. No Docker, no VMs, just the simplest path to production.

What you'll need

  • An Azure subscription (free tier works)
  • Your Flask app with a requirements.txt
  • Azure CLI installed locally

Step 1 — Create the App Service

In the Azure Portal, search for App Services and click Create. Choose your subscription, create or select a Resource Group, give it a name (this becomes your *.azurewebsites.net URL), and select Python 3.9 on Linux.

For the pricing plan, Basic B1 (~$13/month) is the sweet spot for a personal app — it stays always-on unlike the Free tier.

Step 2 — Prepare your app

Add a requirements.txt at your project root:

flask==3.0.0
gunicorn==21.2.0

Add a startup command. In App Service → Configuration → General Settings, set:

gunicorn --bind=0.0.0.0 --timeout 600 server:app

Step 3 — Deploy via zip

The simplest deploy method — zip your project and push it:

cd your-project-folder
zip -r deploy.zip . -x "*.db" -x "__pycache__/*" -x ".git/*"

az webapp deployment source config-zip \
  --resource-group YOUR_RG \
  --name YOUR_APP_NAME \
  --src deploy.zip
Exclude your .db files from the zip — you'll upload those separately via the Kudu file browser so your data doesn't get overwritten on each deploy.

Step 4 — Add your custom domain

In App Service → Custom Domains, click Add custom domain. Azure will give you a CNAME value to add at your DNS provider (Squarespace, Cloudflare, etc.). Once the DNS propagates, come back and click Validate.

Step 5 — Free SSL certificate

Once the domain is verified, go to TLS/SSL Settings → Private Key Certificates → Create App Service Managed Certificate. Select your domain, hit Create — Azure handles renewal automatically.

Done

Your Flask app is now running at https://yourdomain.com with auto-renewing SSL. Total additional cost: ~$13/month.

← All Posts