Skip to content

How the Labs Work

Each lab in this book is carefully designed to simulate real-world scenarios and help you gain hands-on experience with building scalable infrastructure for microservices on Azure using Terraform and Kubernetes. The labs follow a consistent structure to ensure clarity, ease of understanding, and reusability.

Every lab adds to the same platform and the same Terraform repository, so work through them in order. As the labs are rewritten around that repository, each one gets a "Sample code" tip under its title that links to the matching files on GitHub; if something doesn't work, compare your files with the sample.

Here’s what you can expect in every lab, in this order.

Introduction

This section provides a brief overview of the lab's concepts and definitions. It serves as a quick introduction to get you familiarized with the lab and ready to perform the necessary actions. If you require in-depth knowledge on a specific topic, you can refer to the links provided at the end of each lab.

Technical Scenario

This section explains what the online store needs from this lab and why. It ties the lab to the running system, so you can relate it to your own microservices architecture on Kubernetes.

Objective

This section presents the objective of the lab and lists every task you will perform.

For example:

In this exercise, we will accomplish and learn how to implement the following:

- Task-1: Define and declare variables
- Task-2: Create an Azure service using Terraform
- Task-3: Plan and apply the change
- Task-4: Validate the result

Prerequisites

This section lists the previous labs this one builds on, and any tools or software you need. Ensuring you have the necessary prerequisites in place beforehand will help you avoid interruptions during the lab.

For example:

- The previous lab completed, and its resources still running
- Azure CLI and Terraform installed
- Signed in to Azure (see "Sign in to Azure" below)

Architecture Diagram

This section shows what the lab builds and how it connects to what already exists, as a diagram. Diagrams are helpful in visualizing the connections and relationships between components, making it easier to understand the overall scenario.

Cost

This section says what the lab's new resources cost per day in the dev environment, with the date the price was checked, and which settings drive the cost. Prices change; use the Azure pricing calculator for your region.

Implementation Details

Step-by-step implementation details are covered in numbered tasks. The code in each task is the same code as in the sample, trimmed to the part the task explains.

For example:

Task-1: Define and declare variables

Task-1 implementation details go here.

Source code or commands related to Task-1 will be placed here

Task-2: Create an Azure service using Terraform

Task-2 implementation details go here.

Source code or commands related to Task-2 will be placed here

Validate

This section proves that the lab worked, with commands you can run and the output you should expect. Where a resource is private, the check runs from inside the cluster, because that's where the store reaches it from.

Cleanup

Each lab says what to keep for the next lab and how to remove only this lab's resources if you stop here. Because every lab builds on the previous one, the usual advice is to keep everything running while you work through the book, and to destroy the whole environment with terraform destroy when you take a longer break.

Conclusion

This section sums up what you built and learned, and what the next lab adds.

References

This section will cover a list of references for further reading and additional actions.

For example:

Sign in to Azure

Most labs start by signing in to Azure and selecting the subscription the book uses. Labs link to this section instead of repeating it. Run it in Visual Studio Code's terminal before you start a lab.

Bash
# Sign in to Azure
az login

# Show the current subscription and list the others
az account show
az account list --output table

# Select the subscription the book uses
az account set -s "<subscription-name>"

# Let Terraform use the same subscription
export ARM_SUBSCRIPTION_ID=$(az account show --query id -o tsv)
PowerShell
# Sign in to Azure
az login

# Show the current subscription and list the others
az account show
az account list --output table

# Select the subscription the book uses
az account set -s "<subscription-name>"

# Let Terraform use the same subscription
$env:ARM_SUBSCRIPTION_ID = az account show --query id -o tsv

For Kubernetes labs, also connect kubectl to the cluster. The cluster uses Microsoft Entra ID sign-in, so kubelogin reuses your Azure CLI session instead of a stored admin password:

az aks get-credentials --resource-group rg-store-aks-dev --name aks-store-dev
kubelogin convert-kubeconfig -l azurecli
kubectl get nodes

Pointer Pages and Legacy Labs

Some older pages have kept their web address so that existing links keep working, even though their content moved or was replaced.

A pointer page is a lab whose content is now part of another lab. It looks like this:

# <Original title>

This lab is now part of [<New lab title>](<path-to-new-lab>.md#<section>).

It moved because <one-sentence reason>.

A legacy lab is an older lab kept for reference after a newer chapter replaced it. It starts with a warning like this:

!!! warning "Legacy lab"
    This lab is kept for reference. [<New chapter title>](<path-to-new-chapter>.md) replaces it.

Note

The above lab format will be consistently followed throughout the book, providing clear implementation details for each task and guiding you through the practical steps necessary to complete the labs.

Important

Each lab in this book covers actual implementation details, therefore it is always recommended to read the relevant Microsoft Learn documentation on the particular Azure service before you start a lab, so that it's super easy for you to work on these labs. You will see the links at the end of each lab for your reference.