Identity & governance · Lesson 6 of 24

Cost, Advisor and the command line

Watching the bill before it arrives, taking Azure's free advice, and recognising the commands the exam shows you.

About 10 min · Interactive · 3 practice questions

Exam objective
Manage costs by using alerts, budgets and Azure Advisor recommendationsManage Azure identities and governance · 20–25% of the exam · typical question: "Notify when spend reaches X" and "which Advisor category"; recognising PowerShell vs CLI commands throughout the exam
In one sentence. Azure shows spend daily and lets you set a budget that emails you at a threshold (it never switches anything off by itself); Advisor is a free consultant that lists savings and risks; and every portal action has a PowerShell and a CLI equivalent that you must be able to read.

The problem it solves

Finance gives Dev a limit of A$2,000 a month and wants a warning at 80% and again at 100%. Separately, Ravi suspects some VMs have been idle for weeks. And the exam will show Sarah a line of az or New-Az and ask what it does.

Budgets: an alarm, not a switch

How a budget works

  1. Pick a scopeManagement group, subscription or resource group: RG-Dev for Ravi's team.
  2. Set the amount and periodA$2,000 per month, reset on the 1st; optionally an end date.
  3. Set alert thresholds80% and 100% of actual spend, or of forecast spend (Azure projects the month-end from the trend).
  4. Choose who is toldEmail addresses, or an action group (which can also run automation).
  5. Understand what happens at 100%An email. Nothing stops. To shut VMs down you attach an action group whose action runs an Automation runbook or Logic App that deallocates them.
Quick check

Finance wants an email when RG-Dev reaches 80% and 100% of A$2,000 a month. Which statement is true?

Other cost tools

ToolWhereUse
Cost analysisCost Management › Cost analysisActual and forecast spend by service, resource group, tag, location
Cost alertsCost Management › Cost alertsBudget alerts, credit alerts (prepaid credit running out), department quota alerts
Reservations and savings plansReservationsCommit to 1 or 3 years of a VM size or a spend level for a large discount
Azure Hybrid BenefitVM › ConfigurationReuse Windows Server or SQL Server licences you already own with Software Assurance
Pricing calculatorazure.microsoft.comEstimate before building

Azure Advisor

Advisor shows recommendations in five categories. Each one names the resource, the problem and the fix, and can be postponed or dismissed.

CategoryTypical recommendation
CostShut down or resize VMs under 5% CPU; delete unattached disks; buy a reservation
SecurityEnable MFA; patch; restrict ports (from Defender for Cloud)
ReliabilityEnable backup; use an availability set or zone; add a second VM
Operational excellenceCreate a service health alert; use tags
PerformanceUpgrade to Premium disks; use a closer region

Advisor is free and runs on its own; you can set an alert when a new recommendation appears and a weekly digest email.

Quick check

Which Advisor category flags virtual machines that have run under 5% CPU for weeks?

Reading the command line

The exam does not ask you to write scripts. It shows a command and asks what it does, or lists four commands and asks which achieves a goal. Learn the pattern, not the whole language.

TaskAzure PowerShellAzure CLI
Sign inConnect-AzAccountaz login
Choose the subscriptionSet-AzContext -Subscription Prodaz account set -s Prod
Create a resource groupNew-AzResourceGroup -Name RG1 -Location australiaeastaz group create -n RG1 -l australiaeast
Create a VMNew-AzVM -ResourceGroupName RG1 -Name vm1 -Image Win2022Datacenteraz vm create -g RG1 -n vm1 --image Win2022Datacenter
Stop a VM (deallocate)Stop-AzVM -ResourceGroupName RG1 -Name vm1az vm deallocate -g RG1 -n vm1
Assign a roleNew-AzRoleAssignment -SignInName [email protected] -RoleDefinitionName Reader -ResourceGroupName RG1az role assignment create --assignee [email protected] --role Reader -g RG1
Deploy a templateNew-AzResourceGroupDeployment -ResourceGroupName RG1 -TemplateFile main.bicepaz deployment group create -g RG1 -f main.bicep
  • PowerShell: Verb-AzNoun. Verbs: New, Get, Set, Remove, Start, Stop. Parameters start with a dash and a capital: -ResourceGroupName.
  • CLI: az noun verb. Short options: -g resource group, -n name, -l location, -s subscription.
  • Both run in Cloud Shell (the >_ icon in the portal) with nothing installed on your PC; it asks for a small storage account the first time.
Quick check

Which command creates a resource group named RG1 in Australia East?

Memorise (definitions)

  • Budget = alert only; action group + automation to act
  • Advisor's five categories and what lands in each
  • Reservation, savings plan, Hybrid Benefit
  • Verb-AzNoun vs az noun verb; -g -n -l

Apply (scenarios you must solve)

  • Build a budget with thresholds at the right scope
  • Pick the Advisor tab for a symptom
  • Match a command to its outcome
  • Choose the cheapest option for a steady 3-year workload (reservation + Hybrid Benefit)

You, the admin: the Dev budget

  1. Cost Management › Budgets › + Add. Scope: change to resource group RG-Dev.
  2. Name Dev-Monthly, reset period Monthly, amount 2000.
  3. Alert conditions: Actual 80% → [email protected]; Actual 100% → finance plus the action group AG-Ops.
  4. Optional: AG-Ops contains an Automation runbook that deallocates every VM tagged AutoStop = true.
  5. Weekly: open Advisor › Cost and act on idle VMs and orphaned disks.

Script: az consumption budget create --budget-name Dev-Monthly --amount 2000 --time-grain Monthly --resource-group RG-Dev ...

Recognise the wording. "Notify when spend reaches X" = budget alert. "Stop VMs when spend reaches X" = budget + action group + runbook. "Identify idle VMs" = Advisor › Cost. "Reduce cost of a VM that runs 24×7 for years" = reservation (+ Hybrid Benefit if Windows/SQL licences are owned). "Which command…" = read the noun and verb.

Key points

  • A budget is an alarm, not a switch. It emails at thresholds; stopping resources needs an action group with automation.
  • Advisor has five tabs: Cost, Security, Reliability, Operational excellence, Performance. Idle VMs are under Cost.
  • Command patterns: PowerShell is Verb-AzNoun (New-AzVM); CLI is az noun verb (az vm create) with -g and -n.
  • Reservations and Hybrid Benefit are the two named ways to cut VM cost.

Formal terms: Microsoft Cost Management, budget, cost alert, action group, Azure Advisor, reservation, savings plan, Azure Hybrid Benefit, Cloud Shell, Azure PowerShell (Az module), Azure CLI.

Check your understanding

3 exam-style questions in the formats AZ-104 uses. Each is marked when you check it, with the reasoning.

0 of 3 checked

All scenarios and questions are original. None are taken from the exam, Microsoft's practice assessment or any question bank. PrepToExcel is not affiliated with Microsoft.