https://github.com/georges034302/az-app-service-workflow
Python-Flask API container deployment to Azure App Service using GitHub Actions workflows
https://github.com/georges034302/az-app-service-workflow
appservice azure docker github-actions keyvault python pythonflask
Last synced: 2 months ago
JSON representation
Python-Flask API container deployment to Azure App Service using GitHub Actions workflows
- Host: GitHub
- URL: https://github.com/georges034302/az-app-service-workflow
- Owner: Georges034302
- Created: 2025-05-19T08:51:46.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-04T05:13:13.000Z (about 1 year ago)
- Last Synced: 2025-06-24T06:11:33.386Z (about 1 year ago)
- Topics: appservice, azure, docker, github-actions, keyvault, python, pythonflask
- Language: Dockerfile
- Homepage:
- Size: 62.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## ๐ Employee API (Containerized Python App on Azure App Service)
This project provides a minimal FastAPI-based backend API to simulate an employee directory. The API is packaged into a Docker container, pushed to Azure Container Registry (ACR), and deployed to Azure App Service for Linux using **GitHub Actions**.
---
### ๐ Features
- โ
Python + FastAPI-based backend API
- ๐ฆ Dockerized and deployed to **Azure App Service**
- ๐ CI/CD pipeline with **GitHub Actions**
- ๐ Secure credentials via **GitHub Secrets**
- ๐งช Mock data served from a local JSON file
---
### ๐งช API Endpoints
| Method | Endpoint | Description |
|--------|----------------------------|------------------------------------|
| GET | `/users` | List all employees |
| GET | `/users/{id}` | Get a single employee by ID |
**Full API URLs after deployment:**
- **Get all users:**
```
https://.azurewebsites.net/users
```
- **Get user by ID (example for user 2):**
```
https://.azurewebsites.net/users/2
```
Replace `` with your actual Azure App Service name.
Sample response from `/users`:
```json
[
{"id": 1, "name": "Alice", "role": "Manager", "department": "HR", "city": "Sydney"},
{"id": 2, "name": "Bob", "role": "Developer", "department": "IT", "city": "Melbourne"},
{"id": 3, "name": "Eve", "role": "Analyst", "department": "Finance", "city": "Brisbane"}
]
```
---
### โ๏ธ Setup Instructions
#### 1. ๐ GitHub Actions Workflows
**How these are used in the workflow:**
- **setup-iac.yml**:
*Run once to provision Azure resources and set up infrastructure-as-code (IAC) using the above secrets.*
- **deploy.yml**:
*Used for configuring and deploying the App Service container. This workflow expects all secrets to be present and resources to already exist (created by `setup-iac.yml`).*
---
#### 2. ๐ Project Structure
```
az-app-service-workflow/
โโโ .github/
โ โโโ app/
โ โ โโโ __init__.py
โ โ โโโ main.py
โ โ โโโ data.json
โ โโโ scripts/
โ โ โโโ acr_setup.sh
โ โ โโโ az_login.sh
โ โ โโโ az_setup.sh
โ โ โโโ configure_app_service.sh
โ โ โโโ deploy_app_service_container.sh
โ โ โโโ gh_setup.sh
โ โ โโโ output.sh
โ โ โโโ setup.sh
โ โ โโโ tools_config.sh
โ โโโ workflows/
โ โโโ deploy.yml
โ โโโ setup-iac.yml
โโโ Dockerfile
โโโ requirements.txt
โโโ README.md
```
---
#### 3. โ๏ธ Local Setup & Deployment
I. **Authenticate and configure environment: (Run-Once)**
```bash
cd .github/scripts
bash setup.sh
```
II. **Deploy to Azure (manual run):**
```bash
cd .github/scripts
bash deploy.sh
```
---
#### 4. ๐ CI/CD with GitHub Actions
- Triggered on push to `main` branch.
- deploy.yaml workflow runs on push
- Uses GitHub secrets and scripts to:
- Log in to Azure
- Build and push Docker image to ACR
- Configure App Service to use image
- Deploy container-app to App Service
---
#### 5. ๐ณ Local Docker Run (for testing)
```bash
docker build -t employee-api .
docker run -d -p 80:80 employee-api
```
Access API at: [http://localhost](http://localhost)
---
#### ๐จโ๐ป Author: Georges Bou Ghantous
*This repository demonstrates automated deployment of a Python FastAPI app to Azure App Service and Azure Container Registry (ACR) using GitHub Actions. ๐*