This repository is a template for a Python FastAPI microservice with full DevOps workflow:
- Dockerized application
- Automated tests (pytest)
- CI/CD pipeline (GitHub Actions)
- Deployment to Azure Web App for Containers
- Simple CRUD API (
POST
,GET
,PUT
,DELETE
for/items/{item_id}
) - OpenAPI/Swagger documentation (auto-generated)
- CI pipeline: build, test, and deploy to Azure
- Python 3.11+
- Docker
# Install dependencies
pip install -r requirements.txt
# Run the app
uvicorn app.main:app --reload
The API will be available at http://localhost:8000
pytest app/test_main.py
docker build -t devops-microservice-fastapi .
docker run -p 8000:8000 devops-microservice-fastapi
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- Create an Azure Container Registry
- Create an Azure Web App for Containers
- Add these secrets to your GitHub repository:
AZURE_CONTAINER_REGISTRY_LOGIN_SERVER
AZURE_CONTAINER_REGISTRY_USERNAME
AZURE_CONTAINER_REGISTRY_PASSWORD
AZURE_WEBAPP_NAME
- On push to
main
, your app will be built, tested, and deployed automatically.
MIT