This project shows how a containerized app can be hosted and run on Azure.
Azure services included:
- Azure App Services
- Azure Container Instances
- Azure Container Apps
- Azure Kubernetes Services
- Azure App Services with VNET integration
ℹ️ Info
The setup steps require Azure CLI.
Install Azure CLI as described on https://learn.microsoft.com/en-us/cli/azure/install-azure-cli and runaz login
to authenticate.
ℹ️ Info
All Azure resource creating commands use the region Poland Central. Change it, if required.
Create group AKS Admins:
az ad group create \
--display-name 'AKS Admins' \
--mail-nickname aksadmins \
--description 'Administrators of AKS Clusters are placed in this group' \
--query '{objectId: id, displayName: displayName, mailNickname: mailNickname, description: description}' \
-o table
Add current user to owners and mebers list
az ad group owner add \
--group 'AKS Admins' \
--owner-object-id $(az ad signed-in-user show --query id --output tsv)
az ad group member add \
--group 'AKS Admins' \
--member-id $(az ad signed-in-user show --query id --output tsv)
Deploy sharable resources:
- Azure Container Registry
- Key Vault
- SQL Server
- Private DNS Zone (privatelink.azurewebsites.net)
az deployment sub create \
--name="azure-container-hosting-$(date +%Y%m%d%H%M%S)" \
--location polandcentral \
--template-file bicep/main.bicep \
--parameters aksEntraAdminGroupObjectIds='' skipDemo1WebApps=true skipDemo2ContainerInstances=true skipDemo3ContainerApps=true skipDemo4Aks=true skipDemo5Vnet=true
ℹ️ Info
It's required to have Docker or an equivalent container runtime installed on the system.
scripts/01-build-images.sh && scripts/02-push-to-acr.sh
scripts/03-apply-sql-migrations.sh
Deploy resources:
- App Services + dependencies
- Container Instances + dependencies
- Azure Container Apps + dependencies
- Azure Kubernetes service + dependencies
⚠️ Warning
The code uses the previously created AKS Admins group. If you created the group with another name, replace the name group of in the parameter assignment ofaksEntraAdminGroupObjectIds
in the following command.
az deployment sub create \
--name="azure-container-hosting-$(date +%Y%m%d%H%M%S)" \
--location polandcentral \
--template-file bicep/main.bicep \
--parameters aksEntraAdminGroupObjectIds=$(az ad group show -g 'AKS Admins' --query id -o tsv)
Script configures AKS cluster:
- Add nginx ingress controller
- Configure ingress routes
- Add secret provider class to access key vault
- Deploy app
scripts/04-configure-aks.sh
Run the cleanup script
scripts/06-cleanup.sh
The project hosts an application on multiple Azure container environments. The application is a small beer rating application with a client-server architecture and a small dummy console application.
Applications:
- Demo.BeerRating.Backend
- ASP.NET Web API
- Entity Framework with SQL Server
- Demo.BeerRating.Frontend
- ASP.NET Razor Server Pages
- Demo.BeerRating.Console.BeerQuotes
- .NET Console
Framework and Tools:
- .NET 9
- ASP.NET
- Entity Framework
- Microsoft SQL Server
- Bicep
Connections:
-
Ensure
docker compose
or equivalent is available -
Build container images
scripts/01-build-images.sh
-
Run
docker compose up
from project root folder -
Access applications via frontend: http://localhost:5179