Containerizing your ASP.NET Core Clean Architecture API and orchestrating it locally with Docker Compose is a huge milestone. However, the true test of any modern software pipeline is how smoothly it transitions from your local development machine into a scalable, highly available production cloud environment.
While Kubernetes offers incredible power, managing clusters often introduces unnecessary operational overhead for many enterprise teams. A much leaner, highly reliable approach is deploying containerized web applications directly to Azure App Service (Linux Containers). App Service manages the underlying infrastructure, operating system patches, load balancing, and scaling, while GitHub Actions handles your continuous integration and continuous deployment (CI/CD) automatically.
In this comprehensive guide, we will walk through setting up your Azure resources, configuring secure authentication secrets, and building a fully automated deployment pipeline.
The Architecture of Cloud Container Deployments
The deployment lifecycle follows a clean, automated sequence on every push to your main branch:
Build & Test: GitHub Actions checks out your code, restores dependencies, builds the multi-project solution, and runs your unit and integration test suites.
Container Registry Push: Verified builds are packaged via your Dockerfile, tagged with the unique Git commit SHA, and pushed securely to Azure Container Registry (ACR).
Cloud Provisioning: GitHub Actions authenticates with Azure using a Service Principal and instructs Azure App Service to pull and spin up the newly updated container image.
Step 1: Provisioning Azure Prerequisites
Before configuring your pipeline, ensure you have two core resources set up in your Azure Portal:
Azure Container Registry (ACR): A private Docker registry to store your compiled container images (e.g.,
myenterpriseacr.azurecr.io).Azure App Service (Linux): Created with the Docker Container publishing option, pointing to your ACR registry and specifying an initial startup container.
Step 2: Configuring GitHub Repository Secrets
To allow GitHub Actions to communicate securely with your Azure subscription and push images to ACR without exposing passwords in plain text, you need to configure Repository Secrets.
Generate an Azure Service Principal with Contributor permissions using the Azure CLI:
Bash
az ad sp create-for-rbac --name "GitHubActionsDeploymentSP" --role Contributor --scopes /subscriptions/{your-subscription-id}/resourceGroups/{your-resource-group} --sdk-authCopy the resulting JSON output.
In your GitHub repository, navigate to Settings > Secrets and variables > Actions, click New repository secret, name it
AZURE_CREDENTIALS, and paste the JSON blob.Add three additional secrets required for container authentication and deployment:
REGISTRY_USERNAME: Your ACR username (or Service Principal Client ID).REGISTRY_PASSWORD: Your ACR access key/password.WEB_APP_NAME: The exact name of your Azure App Service.
Join the conversation! Your thoughts help the community grow.