Deploying .NET 5 Microservices to AKS using Terraform and Helm

This blog is for a Microsoft Reactor lab for deploying a .NET Microservice to Azure Kubernetes Service by Brad McCoy — Cloud Engineering Lead from Moula.

In this lab we will be give you hands on experience on deploying applications to Azure Kubernetes Services (AKS) we will be creating the following below:

These are the steps we will take:

  1. Sign up for your free Azure account
  2. Fork Repo’s from GitHub
  3. Install Dependencies
  4. Configure Terraform
  5. Provision Infrastructure
  6. Build/Push .NET 5 API Docker image
  7. Deploy Image with Helm

Sign up for your free Azure account

Sign up here for your free account:

Fork Repo’s from GitHub

There are two repositories we will use one for the infrastructure and one for the other for the API.

Surf Report API:

Install Dependencies

We will now install Terraform and Helm that we will be using to deploy.



Azure Cli:

Docker Desktop:

Configure Terraform

We will use remote state in terraform so we need to create a Azure storage account so that we can store the state there.

if you are not sure what remote state is you can check here:

To create the resources in Azure use the following commands:

# Login To Azure
az login
# Create Resource Group
az group create -location australiaeast -name terraformstate-rg
# Create Storage Account (note: replace <name> with a distinct name)
az storage account create --name <name> --resource-group terraformstate-rg --location australiaeast --sku Standard_LRS
# Create Storage Container
az storage container create --name reactorlab --account-name <name>

Provision Infrastructure

# Login To Azure (if required)
az login
# Initialize Terraform
terraform init
# Terraform Plan
terraform plan
# Terraform Apply
terraform apply

Build/Push .NET 5 Docker image

If you don't have a dockerhub account you can sign up for free:

docker login
docker build . -t reactor-lab
docker tag reactor-lab bradmccoydev/reactor-lab:latest
docker push bradmccoydev/reactor-lab:latest

Deploy Image with Helm

helm install reactor-lab ./chart

Head of Cloud Engineering @ Moula