Hands-On Lab785 words

Lab: Mastering Azure Cost Management & Governance

Describe cost management in Azure

Lab: Mastering Azure Cost Management & Governance

In this lab, you will explore the primary tools used to manage and predict cloud spend within Microsoft Azure. You will practice organizing resources with tags, creating a cost budget, and understanding how different factors influence your monthly bill.

[!WARNING] Remember to run the teardown commands at the end of this lab to avoid ongoing charges for any resources provisioned.

Prerequisites

  • An active Azure Subscription (Free Trial, Pay-As-You-Go, or Student).
  • Azure CLI installed locally or access to the Azure Cloud Shell.
  • Permission to create Resource Groups and assign Tags (Owner or Contributor role).

Learning Objectives

  • Apply metadata to resources using Azure Tags for cost allocation.
  • Navigate the Azure Cost Management + Billing interface.
  • Create a Budget with automated alerts to prevent overspending.
  • Differentiate between the Pricing Calculator and the Total Cost of Ownership (TCO) Calculator.

Architecture Overview

The following diagram illustrates the relationship between resource organization (tags) and the management layer that tracks these costs.

Loading Diagram...

Step-by-Step Instructions

Step 1: Create a Resource Group with Cost Tags

Tags are name-value pairs that help you categorize resources for billing. Without tags, it is difficult to determine which department or project is responsible for a specific cost.

bash
az group create --name brainybee-cost-lab --location eastus --tags Department=Education Project=AZ900Lab
Console Alternative
  1. Search for Resource groups in the Azure Portal.
  2. Click + Create.
  3. Enter brainybee-cost-lab as the name.
  4. Navigate to the Tags tab.
  5. Enter Name: Department, Value: Education. Enter Name: Project, Value: AZ900Lab.
  6. Click Review + create and then Create.

Step 2: Create a Consumption Budget

A budget allows you to set a soft limit on your spending and receive notifications when you reach specific percentages (e.g., 50%, 80%, or 100%) of that limit.

bash
az consumption budget create --amount 10 --budget-name "MonthlyLabBudget" --category "Cost" --time-grain "Monthly" --start-date "2023-10-01" --end-date "2025-10-01" --contact-emails "<YOUR_EMAIL>"

[!TIP] In a real-world scenario, ensure the start date is the first day of the current month.

Console Alternative
  1. Search for Cost Management + Billing.
  2. Click Cost Management on the left menu.
  3. Select Budgets and click + Add.
  4. Set the name to MonthlyLabBudget and the amount to 10 (or your local currency equivalent).
  5. Set up an alert at 80% to notify your email address.

Step 3: Explore the Pricing Calculator

Unlike Cost Management (which tracks actual spend), the Pricing Calculator is used to estimate costs before you deploy any resources.

  1. Navigate to the Azure Pricing Calculator.
  2. Add a "Virtual Machine" to your estimate.
  3. Change the Region and observe how the price fluctuates.
  4. Change the Operating System from Linux to Windows and note the licensing cost increase.

Visualizing the Hierarchy

Cost management is applied across the Azure hierarchy. The higher the level, the more aggregated the cost data becomes.

\begin{center} \begin{tikzpicture}[node distance=1.2cm, every node/.style={draw, rectangle, rounded corners, minimum width=4cm, fill=blue!5, font=\small}] \node (MG) {Management Groups (Policy & Governance)}; \node (SUB) [below of=MG] {Subscriptions (Billing Boundary)}; \node (RG) [below of=SUB] {Resource Groups (Lifecycle Boundary)}; \node (RES) [below of=RG] {Resources (The Cost Drivers)};

\draw[->, thick] (MG) -- (SUB); \draw[->, thick] (SUB) -- (RG); \draw[->, thick] (RG) -- (RES); \end{tikzpicture} \end{center}

Checkpoints

Verification TaskExpected Result
Run az group show -n brainybee-cost-labOutput should show the Department: Education tag.
Check the Budgets blade in PortalMonthlyLabBudget should appear in the list.
Compare TCO vs. Pricing CalculatorTCO is for migration (on-prem vs cloud); Pricing is for new cloud estimates.

Troubleshooting

IssuePossible CauseFix
"Subscription not found"CLI is logged into the wrong tenant.Run az login or az account set --subscription <ID>.
Budget creation failsSome "Free Trial" or "Sponsorship" accounts have restricted API access for budgets.Use the Azure Portal UI to create the budget manually.
Tags not appearing in billingThere is a 24-48 hour delay for tags to populate in Cost Analysis.Wait for the next billing cycle or check the resource directly.

Clean-Up / Teardown

To ensure you are not charged for any accidental resources created during this session, delete the resource group. This will delete all resources within it.

bash
az group delete --name brainybee-cost-lab --yes --no-wait

[!IMPORTANT] The --no-wait flag allows the command to return immediately while Azure processes the deletion in the background.

Cost Estimate

  • Azure Cost Management: Free (standard features).
  • Resource Group / Tags: Free.
  • Budget Alerts: Free (standard tier).
  • Total Lab Cost: $0.00 (Assuming no expensive resources like high-tier VMs were deployed).

Ready to study Microsoft Azure Fundamentals (AZ-900)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free