Simple HelloWorld ASP.NET Core 8.0 MVC application deployed to Azure Container Apps using Terraform and Azure DevOps.
This project demonstrates a complete CI/CD pipeline for deploying a containerized ASP.NET Core application to Azure Container Apps using Terraform infrastructure as code and Azure DevOps pipelines with automated integration testing.
- .NET 8.0 SDK
- Docker
- Azure subscription with Container Apps resources
- Azure Container Registry
- Terraform ~> 1.0
- Chromium browser (for Playwright integration tests)
The application is deployed via Azure DevOps pipeline (Infrastructure/Pipelines/helloworld-dev-pipeline.yml):
- Build - Builds and pushes Docker image to Azure Container Registry (tagged with Build ID)
- TerraformPlan - Runs
terraform planwith unique state file per build - Deploy - Runs
terraform applyto create/update Azure Container App with ingress configuration - Test - Runs Playwright integration tests against the deployed Container App URL
- Teardown - Optionally runs
terraform destroyto remove resources (controlled by pipeline parameter, default: true)
The pipeline requires the following variables:
ContainerRegistrySC- Service connection for Azure Container RegistryAzureResourceManagerSC- Azure subscription service connection with Terraform backend accessContainerRegistryLoginServer- ACR URL (e.g.,ncontracts.azurecr.io)ManagedIdentityName- User-assigned managed identity for ACR authenticationEnvironmentName- Environment name for resource naming (e.g.,poc01,dev)
Build the Docker image locally:
cd HelloWorld
docker build -t example/helloworld -f Dockerfile . --no-cacheRun integration tests:
# Set the URL to test against
$env:HomePageUrl = "https://your-container-app-url.azurecontainerapps.io"
# Build and run tests
dotnet build HelloWorld.IntegrationTests/HelloWorld.IntegrationTests.csproj --configuration Debug
pwsh HelloWorld.IntegrationTests/bin/Debug/net8.0/playwright.ps1 install chromium
dotnet test HelloWorld.IntegrationTests/HelloWorld.IntegrationTests.csproj --configuration DebugRun a single test:
dotnet test HelloWorld.IntegrationTests/HelloWorld.IntegrationTests.csproj --filter "FullyQualifiedName~NavigateToWebsiteRoot"The Terraform configuration in Infrastructure/Terraform/ provides a simple, developer-friendly infrastructure setup:
- main.tf - Container App resource with data sources for existing infrastructure
- variables.tf - Well-documented input variables with sensible defaults
- providers.tf - Azure provider and remote state backend configuration
- outputs.tf - Exposes Container App URL and metadata for pipeline consumption
cd Infrastructure/Terraform
terraform init
terraform plan
terraform apply
terraform output container_app_urlSee Infrastructure/Terraform/README.md for detailed instructions.
- Application: ASP.NET Core 8.0 MVC (C#)
- Container Runtime: Docker
- Cloud Platform: Azure Container Apps
- Infrastructure as Code: Terraform
- Testing: NUnit with Playwright (Chromium)
- CI/CD: Azure DevOps Pipelines
- Container Registry: Azure Container Registry