BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeDesigning Microsoft Azure Infrastructure Solutions (AZ-305)Build Lab — Route the Activity Log into a workspace and query it
Build Lab463 words

Build Lab — Route the Activity Log into a workspace and query it

AZ-305 › Unit 1 › Design solutions for logging and monitoring

Build Lab — Route the Activity Log into a workspace and query it

Build brief

Unit
1 — Identity, governance, monitoring
You need
Your own Azure subscription
Time
25 minutes
Cost
AzureActivity is free to ingest
Interface
Azure CLI

This is the hands-on twin of "Route the logs once, and only where they earn their keep". There you decided which mechanism moves telemetry. Here you build the mechanism, wait for data to land, and query it — including the part nobody tells you about, which is that logs do not arrive instantly and a working pipeline looks broken for the first few minutes.

Cost, honestly

Log Analytics bills for data ingestion and retention, so a workspace pointed at a chatty resource can cost real money. This lab deliberately routes only the subscription Activity Log: AzureActivity is one of the tables documented as free from data ingestion charges, alongside Heartbeat, Usage and Operation. Do not extend this lab to a busy VM or SQL database without reading the pricing page first. Teardown deletes the workspace.

Before you start

  • Azure CLI, and az login completed.
  • Contributor on a subscription — you will create one resource group and one workspace.
  • Roughly 15 minutes of patience between step 3 and step 5. Use it to read the design lab again.

What you are building

Loading Diagram...
Figure 1 — Mermaid diagram

Step 1 — a resource group to hold the workspace

bash
az group create --name bb-lab-logs --location westeurope

Step 2 — create the workspace

bash
az monitor log-analytics workspace create \ --resource-group bb-lab-logs \ --workspace-name bb-lab-workspace \ --location westeurope

Keep the returned id — the next step needs it. You can always fetch it again:

bash
az monitor log-analytics workspace show \ --resource-group bb-lab-logs \ --workspace-name bb-lab-workspace \ --query id -o tsv

Step 3 — route the Activity Log at subscription scope

bash
az monitor diagnostic-settings subscription create \ --name bb-lab-activity \ --location westeurope \ --workspace "$(az monitor log-analytics workspace show --resource-group bb-lab-logs --workspace-name bb-lab-workspace --query id -o tsv)" \ --logs '[{"category":"Administrative","enabled":true},{"category":"Policy","enabled":true}]'

Two things to notice. This is a subscription-scope diagnostic setting — the Activity Log is a subscription-level source, not a per-resource one, which is why it has its own command. And you named a workspace here; you could have added a storage account and an event hub to the same setting, which is exactly the claim the design lab tested.

Step 4 — generate an event to look for

bash
az group create --name bb-lab-evidence --location westeurope

Creating a resource group is itself an Administrative operation, so this is the event you will hunt for.

Step 5 — wait, then query

Give it 10 to 15 minutes. Then:

bash
az monitor log-analytics query \ --workspace "$(az monitor log-analytics workspace show --resource-group bb-lab-logs --workspace-name bb-lab-workspace --query customerId -o tsv)" \ --analytics-query "AzureActivity | where ResourceGroup =~ 'bb-lab-evidence' | project TimeGenerated, OperationNameValue, Caller | take 10" \ -o table

Checkpoint

You should see at least one row naming a resource-group write operation and your own account as Caller.

If you get zero rows, do not assume it is broken. That is the single most useful thing this lab teaches: ingestion latency is real, and every "my logging is not working" incident starts here. Re-run the query a few minutes later before changing anything. Note the customerId in the query above — the workspace GUID, not its resource id. Using the wrong one is the second most common mistake.

Why this matters on the exam

Multiple choice · MediumActivity Log routing

You routed the Activity Log with a command scoped to the SUBSCRIPTION rather than to a resource. What does that tell you about the Activity Log?

Teardown

bash
az group delete --name bb-lab-evidence --yes --no-wait az monitor diagnostic-settings subscription delete \ --name bb-lab-activity --yes az group delete --name bb-lab-logs --yes --no-wait

Deleting the resource group removes the workspace with it. Confirm the subscription setting is gone — this one lives outside the resource group and will otherwise keep routing:

bash
az monitor diagnostic-settings subscription list -o table

If it did not work

Four failures, in the order they usually happen

  1. 1

    The query returns nothing

    Almost always latency, not configuration. Wait and retry before touching anything. Confirm the pipeline exists with az monitor diagnostic-settings subscription list — if your setting is listed and the workspace id is right, the design is correct and you are early.

Next

Re-read the design lab's compare table — diagnostic setting, data export, cross-workspace query. You have now built the first of the three, and the row that said "a copy crosses the boundary; a query does not" should read very differently now that you have watched a copy take fifteen minutes to arrive.

All Designing Microsoft Azure Infrastructure Solutions (AZ-305) Study Resources

Related Notes

  • Cram Sheet — Design solutions for logging and monitoring642 words
  • Design Lab — Route the logs once, and only where they earn their keep338 words
  • Design Solutions for Logging and Monitoring — Lesson4,172 words
  • Design Studio — Design solutions for logging and monitoring744 words
  • Quick Note — Recommend a Logging Solution781 words
  • Recommend a Logging Solution — Lesson4,782 words
  • Quick Note — Recommend a Monitoring Solution737 words
  • Recommend a Monitoring Solution — Lesson6,241 words
  • Quick Note — Recommend a Solution for Routing Logs864 words
  • Recommend a Solution for Routing Logs — Lesson5,386 words
  • AZ-305 Exam Map and Design Decision Playbook652 words
  • Unit 1 Capstone — Design identity, governance, and monitoring solutions668 words

Ready to study Designing Microsoft Azure Infrastructure Solutions (AZ-305)?

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

Start Studying

Ready to study Designing Microsoft Azure Infrastructure Solutions (AZ-305)?

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

Start Studying — Free
Designing Microsoft Azure Infrastructure Solutions (AZ-305) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.

Loading Diagram...
Flowchart, left to right. Subscription<br/>Activity Log connects to Log Analytics<br/>workspace ("diagnostic setting<br/>at SUBSCRIPTION scope"). B connects to KQL query<br/>AzureActivity | take 10. Your az group create<br/>in step 4 connects to Subscription<br/>Activity Log"] -->|"diagnostic setting<br/>at SUBSCRIPTION scope"| B["Log Analytics<br/>workspace ("appears as an<br/>Administrative event").