A production-inspired Azure DevSecOps project that deploys a containerized FastAPI application using Terraform, Docker, Azure Container Apps, Azure Container Registry, Managed Identity, Key Vault, Application Insights, Log Analytics and GitHub Actions with OIDC.
The project demonstrates an end-to-end cloud workflow:
Pull Request
↓
Automated validation
↓
Merge to main
↓
Docker image build
↓
Push to Azure Container Registry
↓
Terraform deployment
↓
Azure Container App update
↓
Post-deployment smoke test
The main goal of this project is not only to deploy an application, but to design and document a secure, automated, observable and cost-conscious cloud platform.
This project demonstrates:
- Infrastructure as Code with Terraform.
- Terraform remote state on Azure Storage.
- Modular Terraform structure.
- Containerized FastAPI application.
- Private container image storage with Azure Container Registry.
- Serverless container hosting with Azure Container Apps.
- Managed Identity-based access.
- Azure RBAC authorization.
- Azure Key Vault secret management.
- Secret value kept out of Terraform state.
- Application telemetry with Azure Monitor OpenTelemetry.
- Log collection with Log Analytics.
- Pull Request validation with GitHub Actions.
- Security scanning with Checkov and Trivy.
- Secretless Azure authentication from GitHub Actions using OIDC.
- Docker image tagging with Git commit SHA.
- Automated post-deployment smoke testing.
The platform is built around two main Azure resource groups:
rg-tfstate-devsecops-container-dev-gwc
Used for Terraform remote state.
rg-devsecops-container-dev-gwc
Used for the application platform resources.
The Azure Container App pulls a private container image from Azure Container Registry using a runtime Managed Identity.
The application reads secrets from Azure Key Vault through a Key Vault secret reference.
Application logs and telemetry are sent to Log Analytics and Application Insights.
GitHub Actions deploys the application using a separate Managed Identity authenticated through OIDC, without storing Azure client secrets in GitHub.
More details are available in:
The CI/CD process is split into two main workflows.
Pull Requests targeting main trigger automated validation:
- Terraform formatting check.
- Terraform validation.
- Docker image build.
- Checkov Infrastructure as Code scan.
- Trivy filesystem and container image scan.
After merging into main, the deployment workflow:
- Authenticates to Azure using GitHub OIDC.
- Builds the Docker image.
- Tags the image with the Git commit SHA.
- Pushes the image to Azure Container Registry.
- Applies the Terraform app stack.
- Updates the Azure Container App.
- Resolves the stable Container App URL.
- Runs a smoke test against the deployed application.
- Writes a deployment summary in GitHub Actions.
More details are available in:
| Area | Technology |
|---|---|
| Application | Python, FastAPI, Uvicorn |
| Containerization | Docker |
| Infrastructure as Code | Terraform |
| Cloud Provider | Microsoft Azure |
| Container Registry | Azure Container Registry |
| Runtime | Azure Container Apps |
| Secrets | Azure Key Vault |
| Identity | User Assigned Managed Identity |
| Access Control | Azure RBAC |
| Observability | Log Analytics, Application Insights, OpenTelemetry |
| CI/CD | GitHub Actions |
| Cloud Authentication | GitHub OIDC |
| Security Scanning | Checkov, Trivy |
| Scripting | PowerShell |
.
├── app/
│ ├── Dockerfile
│ ├── .dockerignore
│ ├── main.py
│ └── requirements.txt
│
├── infra/
│ ├── bootstrap/
│ ├── core/
│ └── app/
│
├── scripts/
│ ├── azure-preflight-checks.ps1
│ ├── local-docker-test.ps1
│ └── smoke-test-container-app.ps1
│
├── docs/
│ ├── architecture.md
│ ├── cleanup.md
│ ├── cost-management.md
│ ├── deployment-flow.md
│ ├── diagrams.md
│ ├── observability.md
│ ├── security.md
│ ├── security-scanning.md
│ ├── troubleshooting.md
│ ├── diagrams/
│ └── screenshots/
│
└── .github/
└── workflows/
├── pr-checks.yml
└── deploy.yml
The Terraform code is split into three stacks:
infra/bootstrap
infra/core
infra/app
Creates the Terraform remote state backend:
- Resource Group for Terraform state.
- Azure Storage Account.
- Blob container for state files.
- Required RBAC assignment for state access.
This stack exists because the remote backend must exist before the other Terraform stacks can use it.
Creates the shared platform infrastructure:
- Application Resource Group.
- Azure Container Registry.
- Log Analytics Workspace.
- Application Insights.
- Azure Key Vault.
- Runtime Managed Identity.
- GitHub Actions Managed Identity.
- Azure Container Apps Environment.
- RBAC role assignments.
- Federated Identity Credential for GitHub Actions OIDC.
Deploys the Azure Container App.
This stack reads outputs from the core stack using Terraform remote state, including:
- ACR login server.
- Container Apps Environment ID.
- Runtime Managed Identity ID.
- Key Vault secret URI.
- Application Insights connection string.
This separation keeps the shared platform foundation independent from the application deployment layer.
The project includes a small FastAPI application designed to validate the platform.
Main endpoints:
| Endpoint | Purpose |
|---|---|
/ |
Basic application response |
/health |
Health check endpoint |
/config |
Non-sensitive runtime configuration |
/version |
Application version and deployed commit SHA |
/secret-status |
Secret loading validation without exposing the secret |
/error-test |
Controlled error endpoint for observability validation |
The app is intentionally simple because the focus of the project is the cloud platform around it.
The application is packaged using Docker.
Container design choices include:
- Python slim base image.
.dockerignoreto keep the image clean.- Non-root application user.
- Exposed port
8000. - Docker healthcheck using
/health. - Uvicorn as the ASGI server.
The image is built locally for validation and automatically in GitHub Actions for deployment.
Security is one of the main focuses of the project.
Key security decisions:
- Azure Container Registry admin user is disabled.
- Container App uses Managed Identity instead of registry credentials.
- Runtime identity has only
AcrPullon ACR. - Runtime identity has only
Key Vault Secrets Useron Key Vault. - GitHub Actions uses a separate Managed Identity.
- GitHub Actions authenticates to Azure through OIDC.
- No Azure client secret is stored in GitHub.
- Secret values are not managed by Terraform.
- Secret values are not committed to Git.
- Terraform state files are not committed to Git.
- Local backend and variable files are ignored.
The project uses two separate Managed Identities:
| Identity | Purpose |
|---|---|
| Runtime Managed Identity | Used by the Azure Container App |
| GitHub Actions Managed Identity | Used by GitHub Actions deployment workflow |
The runtime identity can pull images and read secrets.
The deployment identity can push images, access Terraform remote state and apply infrastructure changes.
This separation prevents the running application from having deployment-level permissions.
More details are available in:
Azure Key Vault is used to store application secrets.
Important design choice:
Terraform creates the Key Vault and RBAC permissions,
but Terraform does not manage the actual secret value.
This is intentional because secret values managed by Terraform can be stored in Terraform state.
The Container App reads the secret using a Key Vault secret reference and the runtime Managed Identity.
The application validates secret loading through:
/secret-status
The endpoint confirms whether the secret is loaded, but it never exposes the secret value.
The project uses:
- Log Analytics for platform and container logs.
- Application Insights for application telemetry.
- Azure Monitor OpenTelemetry for FastAPI telemetry export.
The application receives the Application Insights connection string through environment configuration.
Telemetry initialization is fail-safe:
If telemetry configuration fails,
the application continues to start.
This avoids making observability a single point of failure.
The /error-test endpoint can be used to generate a controlled error and validate exception tracking.
More details are available in:
The repository contains two main workflows.
Workflow file:
.github/workflows/pr-checks.yml
Runs on Pull Requests targeting main.
Jobs:
- Terraform checks.
- Docker build.
- Checkov IaC scan.
- Trivy security scan.
Workflow file:
.github/workflows/deploy.yml
Runs on push to main and manual dispatch.
Main steps:
- Checkout repository.
- Set up Terraform.
- Azure login with OIDC.
- Resolve ACR login server.
- Log in to ACR.
- Build Docker image.
- Push Docker image.
- Create temporary Terraform backend configuration.
- Terraform init, validate, plan and apply.
- Resolve Container App URL.
- Run smoke test.
- Write deployment summary.
The deployment workflow runs a smoke test after Terraform apply.
Smoke test script:
scripts/smoke-test-container-app.ps1
The smoke test validates:
/health/config/version/secret-status
It checks that:
- The app is healthy.
- The runtime environment is correct.
- The Azure region is correct.
- The app runs on Azure Container Apps.
- Application Insights is configured.
- The deployed commit SHA matches the expected GitHub commit.
- The Key Vault secret is loaded.
- The secret value is not exposed.
This ensures that the workflow validates the real application behavior, not only the Terraform deployment result.
This project is designed for a personal development and portfolio environment.
Cost-conscious choices include:
- Azure Container Apps instead of AKS.
- Azure Container Registry Basic SKU.
- Minimum replicas set to
0. - Maximum replicas set to
1. - No Azure Firewall in version 1.
- No NAT Gateway in version 1.
- No Private Endpoints in version 1.
- No Application Gateway or WAF in version 1.
- Single development environment.
These choices reduce cost and complexity while still demonstrating strong cloud engineering practices.
The project does not claim to be a fully private enterprise production platform.
Instead, it is a realistic and explainable development platform that can be hardened further for production.
More details are available in:
Future improvements could include:
- Separate dev, staging and production environments.
- GitHub Environments with approval gates.
- Private Endpoints for Key Vault, ACR and Storage.
- Private Container Apps Environment.
- Application Gateway with WAF.
- Controlled egress through Azure Firewall or NAT Gateway.
- More restrictive custom RBAC roles.
- Azure Policy enforcement.
- Stronger Checkov blocking rules.
- Image signing.
- SBOM generation.
- Container image cleanup policy.
- Alert rules and action groups.
- Custom Application Insights dashboards.
- Availability tests.
- More detailed OpenTelemetry spans.
- Structured JSON logging.
- Microsoft Defender for Cloud integration.
Required tools:
- Git
- Docker Desktop
- Azure CLI
- Terraform
- PowerShell
.\scripts\local-docker-test.ps1This script builds the Docker image, runs the container locally and validates the main endpoints.
.\scripts\azure-preflight-checks.ps1This script checks local tools, Azure login, Docker Engine status and required Azure resource providers.
$appFqdn = az containerapp show `
--name ca-devsecops-api-dev-gwc `
--resource-group rg-devsecops-container-dev-gwc `
--query "properties.configuration.ingress.fqdn" `
-o tsv
$appUrl = "https://$appFqdn"
$expectedSha = git rev-parse HEAD
.\scripts\smoke-test-container-app.ps1 `
-AppUrl $appUrl `
-ExpectedCommitSha $expectedShaThis project uses remote Terraform state.
The real backend configuration and variable files are intentionally not committed.
Ignored files include:
terraform.tfvars
backend.tf
.terraform/
*.tfstate
*.tfstate.*
.env
Example files should be used as templates when reproducing the project.
Cleanup must be done in the correct order:
1. infra/app
2. infra/core
3. infra/bootstrap
The app stack should be destroyed first because it depends on the core infrastructure.
The bootstrap stack should be destroyed last because it contains the Terraform remote state backend.
More details are available in:
Real issues encountered during the project are documented in:
Covered topics include:
- Docker Engine not running.
- Terraform module initialization.
- Azure resource provider registration.
- Key Vault RBAC propagation delay.
- Container App unavailable page.
- Application telemetry fail-safe behavior.
- Trivy unfixed vulnerabilities.
- Checkov findings in a development environment.
- App Registration permission issues.
- GitHub Actions OIDC validation.
- Smoke test failures.
| Document | Description |
|---|---|
| Architecture Overview | Main Azure architecture and Terraform stack separation |
| Deployment Flow | Pull Request, CI/CD and deployment flow |
| Security Model | Managed Identity, RBAC, Key Vault and OIDC model |
| Security Scanning | Checkov and Trivy scanning strategy |
| Observability | Log Analytics, Application Insights and telemetry |
| Troubleshooting | Real issues encountered and how they were solved |
| Cost Management | Cost-conscious design decisions |
| Cleanup Guide | Safe infrastructure destroy order |
| Diagrams | Architecture, CI/CD, identity and secret flow diagrams |
This project demonstrates the ability to:
- Design a cloud-native Azure container platform.
- Use Terraform to manage infrastructure.
- Split Terraform into maintainable stacks.
- Use remote state safely.
- Containerize and deploy an application.
- Use Azure Container Registry securely.
- Deploy to Azure Container Apps.
- Use Managed Identity and RBAC.
- Store secrets in Key Vault.
- Avoid static cloud credentials in CI/CD.
- Configure GitHub Actions OIDC.
- Add Infrastructure as Code security scanning.
- Add container image vulnerability scanning.
- Configure observability with Application Insights.
- Validate deployments with smoke tests.
- Document architecture, security, cost and troubleshooting decisions.
The final platform provides a complete DevSecOps workflow:
Developer opens a Pull Request
↓
GitHub Actions validates Terraform, Docker and security scans
↓
Pull Request is merged into main
↓
GitHub Actions authenticates to Azure using OIDC
↓
Docker image is built and pushed to Azure Container Registry
↓
Terraform updates the Azure Container App
↓
The deployed app is validated with smoke tests
↓
Logs and telemetry are available through Azure observability services
The result is a secure, automated, observable and cost-conscious Azure container platform suitable for a professional cloud engineering portfolio.








