Skip to content

Latest commit

 

History

History
151 lines (87 loc) · 5.63 KB

File metadata and controls

151 lines (87 loc) · 5.63 KB

User: Deploy this FastAPI app on Azure App Service. I have already created the web app project on Azure. Earlier it was hosted on AWS EC2 and ran via gunicorn src.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8080

GitHub Copilot:

Created 4 todos

Read

Read

Read

Read

Starting: Create Azure startup command (2/4)

Key observations:

  • The app entry point is src.main:app (imports use relative module names like models.settings, so the working directory must be src)
  • Root requirements.txt has the full dependencies
  • The AWS setup used gunicorn src.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8080

Azure App Service for Linux (Python) expects the app code at the repo root and uses port 8000 by default. I'll create the necessary configuration files.

Created

Created

Starting: Create Azure deployment configs (3/4)

Ran terminal command: chmod +x /Users/user/Documents/foss42/dev/foss42-apis/startup.sh

Now let me create the Azure deployment instructions document:

Created

Completed: Create Azure deployment configs (3/4)

Here's what I created for the Azure App Service deployment:

Files added

File Purpose
startup.sh Custom startup script — cds into src and runs gunicorn with 4 uvicorn workers on port 8000 (Azure's default)
.deployment Tells Azure's Oryx build system to run pip install -r requirements.txt during deployment
azure_instructions.md Full deployment guide with CLI commands

Quick deploy steps

  1. Set the startup command on your existing web app:

    az webapp config set \
      --name <app-name> \
      --resource-group <resource-group> \
      --startup-file "startup.sh"
  2. Deploy via ZIP:

    zip -r deploy.zip . -x ".git/*" "__pycache__/*" "*.pyc" ".env" "deploy.zip"
    az webapp deploy --name <app-name> --resource-group <resource-group> --src-path deploy.zip --type zip
  3. Verify:

    curl https://<app-name>.azurewebsites.net/

Key difference from AWS

  • Azure App Service uses port 8000 (not 8080), so startup.sh binds to 0.0.0.0:8000.
  • The startup script cds into src first so the module imports (from models.settings import settings, etc.) resolve correctly — matching the main:app entry point rather than src.main:app.
  • Azure's build system automatically installs from the root requirements.txt during deployment.

Made changes.

User: % az zsh: command not found: az

GitHub Copilot:

Azure CLI isn't installed yet. Let me install it via Homebrew:

Ran terminal command: brew install azure-cli

Ran terminal command: az version

Read , lines 1 to 20

Searched for text azure-cli (**//Users/user/Library/Application Support/Code/User/workspaceStorage/83c02875db1106a41bfbbca95172ded2/GitHub.copilot-chat/chat-session-resources/773b31f3-fc2d-49d8-b3f8-103731ac10df/toolu_01WqW7H7r43shmmBBn8fGQRL__vscode-1771081213370/content.txt), no results

Ran terminal command: which az && az version 2>&1 | head -10

Azure CLI is now installed — v2.83.0. Next step is to log in:

az login

This will open your browser for Azure authentication. Once logged in, you can proceed with the deployment commands from azure_instructions.md.

User: next

GitHub Copilot:

Let me find your existing Azure Web App:

Ran terminal command: az webapp list --output table 2>&1

Found it. Now let me configure and deploy:

Created 3 todos

Ran terminal command: az webapp config set --name foss42 --resource-group foss42-resource_group --startup-file "startup.sh" --output table 2>&1

Good — startup command is set. The runtime shows PYTHON|3.12, which is fine. Now let me deploy:

Starting: Deploy via ZIP (2/3)

Ran terminal command: rm -f deploy.zip && zip -r deploy.zip . -x ".git/" "pycache/" ".pyc" ".env" "deploy.zip" "/pycache/*"

Ran terminal command: az webapp deploy --name foss42 --resource-group foss42-resource_group --src-path deploy.zip --type zip 2>&1 Completed with input: az webapp deploy --name foss42 --resource-group foss42-resource_group --src-path deploy.zip --type zip 2>&1

The ZIP deploy got a 502 from Kudu (common transient issue). Let me retry with the az webapp up approach instead, which is more reliable:

Ran terminal command: az webapp deploy --name foss42 --resource-group foss42-resource_group --src-path deploy.zip --type zip --timeout 300 2>&1

User: Wbsite is running thanks

GitHub Copilot:

Created 3 todos

Great, your FastAPI app is live at https://<foss42>.azurewebsites.net.

For future deployments, just re-run the zip + deploy commands:

rm -f deploy.zip && zip -r deploy.zip . -x ".git/*" "__pycache__/*" "*.pyc" ".env" "deploy.zip" "*/__pycache__/*"
az webapp deploy --name foss42 --resource-group foss42-resource_group --src-path deploy.zip --type zip

You can also clean up the local deploy.zip since it's no longer needed.