In this workshop you'll learn how to deploy applications to Azure Kubernetes Service using Docker Application Templates and GitHub Actions.
This is what you'll be doing:
-
create a GitHub repository to store your demo code and the credentials to deploy to Azure
-
run a Docker Application Template which generates code and a CI/CD pipelie for the .NET Core demo app eShopOnWeb
-
push your local code to GitHub which runs a workflow to create an Azure SQL database and an Azure Kubernetes Service cluster
-
run the app locally in Docker containers to see how it works, and make some simple changes
-
push the changed code to GitHub which runs a workflow to build Docker images, push them to Docker Hub, and deploy the app onto your AKS cluster.
It sounds like a lot, but it's really simple because the template generates documentation for you which guides you through all the steps.
You'll need a few things before you start:
- A version of Docker Desktop with Application Templates enabled.
The demo is a Linux app, so on Windows you need to use Linux container mode. That's the default so you only need to change it if you've switched to Windows container mode.
-
A Docker Hub account, so the pipeline can push the Docker images it builds, and the Kubernetes cluster can pull them.
-
Some tools to work with the source code - Git and Visual Studio Code. If you have Chocolatey set up you can install them with:
choco install -y git
choco install -y visualstudiocode
- A Service Principal in Azure, which the pipline uses to manage resources when you deploy. You can use the Azure CLI or Azure Cloud Shell to run this command:
az ad sp create-for-rbac --name http://eshoponazure
Make a note of the output, you'll need to add the details to GitHub
- A GitHub repo. The pipeline runs using GitHub Actions. Create an empty repo and set the following secrets (under Settings...Secrets):
AZURE_SP_APP_ID- Service Principal application IDAZURE_SP_NAME- Service Principal nameAZURE_SP_PASSWORD- Service Principal passwordAZURE_SP_TENANT- Service Principal tenantAZURE_SQL_SERVER_NAME- Name of the SQL Server instance (an existing one or a new one)AZURE_SQL_PASSWORD- Password for SQL Server (any valid SQL Authentication password)DOCKER_HUB_USERNAME- Docker Hub usernameDOCKER_HUB_ACCESS_TOKEN- Docker Hub Personal Access Token
Update your App Template config in ~/.docker/application-template/preferences.yaml to include the template library at https://raw.githubusercontent.com/sixeyed/eshoponazure-workshop/master/eshop-library.yaml.
This example includes the local demo libraries and the main Docker library:
apiVersion: v1alpha1
disableFeedback: false
kind: Preferences
repositories:
- name: eshoponazure
url: https://raw.githubusercontent.com/sixeyed/eshoponazure-workshop/master/eshop-library.yaml
- name: library
url: https://docker-application-template.s3.amazonaws.com/production/v0.1.5/library.yaml
Right-click the Docker whale icon in your taskbar and select Design new application... A window launches asking if you want to choose an existing template or design a custom app; select Choose a template.
If you're running Docker Desktop on Windows you'll be asked if you want to run a Linux or Windows app - the template we'll be using is Linux so select Linux.
Now select the eShop on Web template from the gallery:
From here you'll need to add some details about the deployment, which the template captures as parameters:
-
GitHub Username and Repository name - use the repo you created earlier with all the secrets stored for Azure and Docker Hub
-
Azure resource group name - any name you like for the resource group to create
-
AKS Cluster name - any name for the cluster to create
The other parameters have default values, and you can leave them as they are or change them to suit your deployment.
The SQL Server password is onyl used when you run the app locally, the Azure deployment uses the password you stored in the GitHub secret
Now click Continue, give your application a name and click Scaffold. Docker Desktop runs the template and generates the source code and GitHub workflows on you local machine.
When the scaffolding process finishes click Run application. That builds and runs the app in local containers. While it's building click Open in Visual Studio Code to launch a VS Code instance with the generated application code:
Now you can follow the generated documentation from the source code. Browse to the README file in the eshop-web folder and contine from there.
Good luck :)


