Skip to content

Monitor and Maintain Azure Resources - Q&A

This document contains comprehensive questions and answers for the Monitor and Maintain Azure Resources domain of the AZ-104 exam (10-15% weight).


Section 1: Azure Monitor

Q1.1: What is Azure Monitor and what are its components?

Answer: Azure Monitor is a comprehensive monitoring solution for collecting, analyzing, and acting on telemetry from Azure and on-premises environments.

Core Components:

ComponentDescription
MetricsNumerical time-series data
LogsText-based records in Log Analytics
AlertsNotifications based on conditions
InsightsPre-built monitoring solutions
WorkbooksInteractive reports

Data Sources:

  • Application (Application Insights)
  • Operating system (Azure Monitor Agent)
  • Azure resources (Platform metrics/logs)
  • Azure subscription (Activity log)
  • Azure tenant (Entra ID logs)
  • Custom sources (APIs)

Data Destinations:

  • Metrics database (90 days retention)
  • Log Analytics workspace (configurable retention)
  • Azure Storage (long-term archive)
  • Event Hubs (streaming to external systems)

Key Features:

bash
# View available metrics for a resource
az monitor metrics list-definitions \
  --resource "/subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachines/myVM"

# Get metric values
az monitor metrics list \
  --resource "/subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachines/myVM" \
  --metric "Percentage CPU" \
  --interval PT1H

Documentation Links:


Q1.2: What is the difference between metrics and logs?

Answer: Metrics and logs serve different monitoring purposes.

Metrics:

  • Numerical values at regular intervals
  • Lightweight, near real-time
  • Stored in time-series database
  • 90-day retention (free)
  • Best for alerting and dashboards

Logs:

  • Rich, structured data
  • Variable schema
  • Stored in Log Analytics workspace
  • Configurable retention (up to 2 years)
  • Best for deep analysis and troubleshooting

Comparison:

AspectMetricsLogs
Data typeNumbersText/structured
CollectionAutomaticConfigured
LatencyNear real-timeMinutes
QueryMetrics ExplorerKQL
CostFree (90 days)Per GB ingested
Use caseDashboards, alertsAnalysis, troubleshooting

Platform Metrics vs Custom Metrics:

Platform Metrics:

  • Automatically collected
  • No configuration needed
  • Standard Azure resource metrics

Custom Metrics:

  • Application-defined
  • Sent via API or agent
  • Business-specific data

Diagnostic Settings:

bash
# Enable diagnostic settings for a resource
az monitor diagnostic-settings create \
  --resource "/subscriptions/.../resourceGroups/.../providers/Microsoft.Storage/storageAccounts/mystorage" \
  --name "SendToLogAnalytics" \
  --workspace "/subscriptions/.../resourceGroups/.../providers/Microsoft.OperationalInsights/workspaces/myworkspace" \
  --logs '[{"category": "StorageRead", "enabled": true}]' \
  --metrics '[{"category": "Transaction", "enabled": true}]'

Documentation Links:


Q1.3: What is the Activity Log?

Answer: The Activity Log records subscription-level events in Azure.

Event Categories:

CategoryDescription
AdministrativeCreate, update, delete operations
Service HealthAzure service incidents
Resource HealthResource availability changes
AlertAlert activations
AutoscaleScaling events
RecommendationAzure Advisor recommendations
SecuritySecurity Center alerts
PolicyAzure Policy events

Viewing Activity Log:

bash
# List activity log events
az monitor activity-log list \
  --resource-group "MyResourceGroup" \
  --start-time "2025-01-01T00:00:00Z" \
  --end-time "2025-01-31T23:59:59Z"

# Filter by operation
az monitor activity-log list \
  --resource-group "MyResourceGroup" \
  --filter "eventTimestamp ge '2025-01-01' and operationName.value eq 'Microsoft.Compute/virtualMachines/write'"

Activity Log Retention:

  • 90 days in Azure portal (free)
  • Export to Log Analytics for longer retention
  • Export to Storage for archival

Exporting Activity Log:

bash
# Create diagnostic setting for subscription
az monitor diagnostic-settings subscription create \
  --name "ExportActivityLog" \
  --location "global" \
  --workspace "/subscriptions/.../resourceGroups/.../providers/Microsoft.OperationalInsights/workspaces/myworkspace" \
  --logs '[{"category": "Administrative", "enabled": true}, {"category": "Security", "enabled": true}]'

Documentation Links:


Section 2: Alerts and Action Groups

Q2.1: What are the types of alerts in Azure Monitor?

Answer: Azure Monitor supports multiple alert types for different scenarios.

Alert Types:

TypeData SourceUse Case
Metric alertsMetricsResource performance
Log alertsLog AnalyticsComplex queries
Activity log alertsActivity logAdministrative events
Service health alertsService HealthAzure outages
Smart detectionApplication InsightsAnomaly detection

Metric Alert Example:

bash
# Create metric alert for high CPU
az monitor metrics alert create \
  --name "HighCPUAlert" \
  --resource-group "Monitor-RG" \
  --scopes "/subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachines/myVM" \
  --condition "avg Percentage CPU > 80" \
  --window-size 5m \
  --evaluation-frequency 1m \
  --action "/subscriptions/.../resourceGroups/.../providers/Microsoft.Insights/actionGroups/myActionGroup" \
  --description "Alert when CPU exceeds 80%"

Log Alert Example:

bash
# Create log alert for failed logins
az monitor scheduled-query create \
  --name "FailedLoginsAlert" \
  --resource-group "Monitor-RG" \
  --scopes "/subscriptions/.../resourceGroups/.../providers/Microsoft.OperationalInsights/workspaces/myworkspace" \
  --condition "count > 5" \
  --condition-query "SecurityEvent | where EventID == 4625" \
  --window-size 15m \
  --evaluation-frequency 5m \
  --action "/subscriptions/.../resourceGroups/.../providers/Microsoft.Insights/actionGroups/myActionGroup"

Activity Log Alert Example:

bash
# Create alert for VM deletion
az monitor activity-log alert create \
  --name "VMDeletedAlert" \
  --resource-group "Monitor-RG" \
  --condition category=Administrative and operationName="Microsoft.Compute/virtualMachines/delete" \
  --action-group "/subscriptions/.../resourceGroups/.../providers/Microsoft.Insights/actionGroups/myActionGroup"

Alert States:

  • New: Alert fired, not acknowledged
  • Acknowledged: Being investigated
  • Closed: Resolved

Documentation Links:


Q2.2: What are Action Groups?

Answer: Action Groups define notification and automation actions triggered by alerts.

Action Types:

ActionDescription
Email/SMS/Push/VoiceNotify people
Azure FunctionRun serverless code
Logic AppRun workflow
WebhookCall external URL
ITSMCreate ticket in ITSM tool
Automation RunbookRun Azure Automation
Event HubStream to Event Hub
Secure WebhookWebhook with Entra auth

Creating Action Group:

bash
# Create action group with email and SMS
az monitor action-group create \
  --name "ITOpsTeam" \
  --resource-group "Monitor-RG" \
  --short-name "ITOps" \
  --action email admin admin@contoso.com \
  --action sms oncall 1 5551234567

# Create action group with webhook
az monitor action-group create \
  --name "AutoRemediation" \
  --resource-group "Monitor-RG" \
  --short-name "AutoRem" \
  --action webhook remediate https://myfunction.azurewebsites.net/api/remediate

Action Group Limits:

  • 10 email actions per group
  • 10 SMS actions per group
  • 10 voice actions per group
  • 10 webhook actions per group
  • 5 ITSM actions per group

Rate Limits:

  • SMS: 1 per 5 minutes
  • Voice: 1 per 5 minutes
  • Email: 100 per hour

Documentation Links:


Section 3: Log Analytics

Q3.1: What is Log Analytics?

Answer: Log Analytics is a tool for querying and analyzing log data collected by Azure Monitor.

Key Components:

Log Analytics Workspace:

  • Central repository for log data
  • Configurable retention (30 days to 2 years)
  • Access control via RBAC
  • Multiple data sources

Creating Workspace:

bash
# Create Log Analytics workspace
az monitor log-analytics workspace create \
  --resource-group "Monitor-RG" \
  --workspace-name "MyWorkspace" \
  --location "eastus" \
  --retention-time 90

Data Collection:

  • Azure resources (diagnostic settings)
  • VMs (Azure Monitor Agent)
  • Applications (Application Insights)
  • Custom sources (Data Collector API)

Workspace Architecture Options:

DesignDescriptionUse Case
CentralizedSingle workspaceSmall organizations
DecentralizedWorkspace per team/regionLarge organizations
HybridMix of bothComplex requirements

Access Control:

  • Workspace-level: Access to all data
  • Resource-level: Access to specific resource data
  • Table-level: Access to specific tables

Documentation Links:


Q3.2: What is Kusto Query Language (KQL)?

Answer: KQL is the query language used to analyze data in Log Analytics.

Basic Query Structure:

kusto
TableName
| where TimeGenerated > ago(1h)
| where Column == "value"
| summarize count() by AnotherColumn
| order by count_ desc

Common Operators:

OperatorDescriptionExample
whereFilter rowswhere Status == "Error"
projectSelect columnsproject Name, Status
summarizeAggregatesummarize count() by Type
order bySortorder by TimeGenerated desc
takeLimit rowstake 100
extendAdd columnextend Duration = EndTime - StartTime
joinCombine tablesjoin kind=inner Table2 on Id
renderVisualizerender timechart

Common Functions:

FunctionDescriptionExample
ago()Time offsetago(1h), ago(7d)
now()Current timenow()
count()Count rowssummarize count()
avg()Averagesummarize avg(Value)
sum()Sumsummarize sum(Bytes)
bin()Time bucketsbin(TimeGenerated, 1h)
containsString searchwhere Message contains "error"

Example Queries:

VM CPU Usage:

kusto
Perf
| where ObjectName == "Processor" and CounterName == "% Processor Time"
| where TimeGenerated > ago(1h)
| summarize AvgCPU = avg(CounterValue) by Computer, bin(TimeGenerated, 5m)
| render timechart

Failed Sign-ins:

kusto
SigninLogs
| where ResultType != 0
| where TimeGenerated > ago(24h)
| summarize FailedAttempts = count() by UserPrincipalName, IPAddress
| order by FailedAttempts desc
| take 10

Storage Operations:

kusto
StorageBlobLogs
| where TimeGenerated > ago(1h)
| where StatusCode >= 400
| summarize ErrorCount = count() by OperationName, StatusCode
| order by ErrorCount desc

Resource Changes:

kusto
AzureActivity
| where OperationNameValue endswith "write" or OperationNameValue endswith "delete"
| where TimeGenerated > ago(24h)
| project TimeGenerated, Caller, OperationNameValue, ResourceGroup
| order by TimeGenerated desc

Documentation Links:


Section 4: Azure Backup

Q4.1: What is Azure Backup?

Answer: Azure Backup provides simple, secure, and cost-effective solutions for backing up and recovering data.

Supported Workloads:

WorkloadBackup Method
Azure VMsVM backup (full VM)
Azure FilesFile share backup
SQL in Azure VMSQL backup
SAP HANA in Azure VMSAP HANA backup
Azure BlobsBlob backup
Azure DisksDisk backup
On-premisesMARS agent, MABS, DPM

Backup Components:

Recovery Services Vault:

  • Container for backup data
  • Stores backup policies
  • Manages recovery points
  • Geo-redundant by default

Backup Policy:

  • Schedule (daily, weekly)
  • Retention (days, weeks, months, years)
  • Instant restore snapshots

Creating Backup:

bash
# Create Recovery Services vault
az backup vault create \
  --resource-group "Backup-RG" \
  --name "MyBackupVault" \
  --location "eastus"

# Enable backup for VM
az backup protection enable-for-vm \
  --resource-group "Backup-RG" \
  --vault-name "MyBackupVault" \
  --vm "MyVM" \
  --policy-name "DefaultPolicy"

# Trigger immediate backup
az backup protection backup-now \
  --resource-group "Backup-RG" \
  --vault-name "MyBackupVault" \
  --container-name "IaasVMContainer;iaasvmcontainerv2;Compute-RG;MyVM" \
  --item-name "VM;iaasvmcontainerv2;Compute-RG;MyVM" \
  --retain-until "2025-12-31"

Backup Storage Redundancy:

TypeDescription
LRS3 copies in single datacenter
ZRS3 copies across zones
GRS6 copies across regions

Documentation Links:


Q4.2: How do you restore from Azure Backup?

Answer: Azure Backup provides multiple restore options depending on the workload.

VM Restore Options:

OptionDescriptionUse Case
Create new VMRestore to new VMReplace failed VM
Replace existingRestore disks to existing VMIn-place recovery
Restore disksRestore disks onlyCustom recovery
Cross-regionRestore to secondary regionDR scenario
File recoveryMount disks, copy filesRecover specific files

Restoring VM:

bash
# List recovery points
az backup recoverypoint list \
  --resource-group "Backup-RG" \
  --vault-name "MyBackupVault" \
  --container-name "IaasVMContainer;iaasvmcontainerv2;Compute-RG;MyVM" \
  --item-name "VM;iaasvmcontainerv2;Compute-RG;MyVM"

# Restore VM
az backup restore restore-disks \
  --resource-group "Backup-RG" \
  --vault-name "MyBackupVault" \
  --container-name "IaasVMContainer;iaasvmcontainerv2;Compute-RG;MyVM" \
  --item-name "VM;iaasvmcontainerv2;Compute-RG;MyVM" \
  --rp-name "RecoveryPointName" \
  --storage-account "mystorageaccount" \
  --target-resource-group "Restore-RG"

File Recovery:

  1. Generate recovery script from portal
  2. Run script to mount recovery point as drive
  3. Copy needed files
  4. Unmount when complete

Instant Restore:

  • Snapshots stored locally (1-5 days)
  • Faster restore from snapshot
  • No need to copy from vault

Documentation Links:


Section 5: Azure Site Recovery

Q5.1: What is Azure Site Recovery?

Answer: Azure Site Recovery (ASR) provides disaster recovery by replicating workloads to a secondary location.

Supported Scenarios:

SourceTarget
Azure VMAnother Azure region
VMware VMAzure
Hyper-V VMAzure
Physical serversAzure
Azure VMAnother Azure region

Key Components:

Replication:

  • Continuous data replication
  • Application-consistent snapshots
  • Crash-consistent snapshots

Recovery Plans:

  • Orchestrated failover
  • Multiple VMs in sequence
  • Custom scripts and actions

Failover Types:

TypeDescriptionUse Case
Test failoverNon-disruptive testDR drills
Planned failoverGraceful failoverMaintenance
Unplanned failoverEmergency failoverDisaster

Setting Up ASR for Azure VMs:

bash
# Enable replication (via portal recommended)
# Key configuration:
# - Source region
# - Target region
# - Replication policy
# - Target resource group
# - Target virtual network

Recovery Plan Example:

Group 1: Database servers (start first)
  - SQL Server VM
  - Wait for SQL to be healthy

Group 2: Application servers
  - App Server 1
  - App Server 2

Group 3: Web servers (start last)
  - Web Server 1
  - Web Server 2

Documentation Links:


Q5.2: What is the difference between Azure Backup and Site Recovery?

Answer: Azure Backup and Site Recovery serve different purposes.

Comparison:

AspectAzure BackupSite Recovery
PurposeData protectionDisaster recovery
RPOHours to daysMinutes
RTOHoursMinutes to hours
ScopeIndividual resourcesEntire workloads
ReplicationPoint-in-time copiesContinuous
CostPer protected instancePer protected instance

When to Use Each:

Azure Backup:

  • Protect against data loss
  • Accidental deletion recovery
  • Ransomware recovery
  • Compliance requirements
  • Long-term retention

Site Recovery:

  • Business continuity
  • Regional outage protection
  • Datacenter migration
  • DR testing
  • Minimal downtime requirements

Combined Strategy:

  • Use both for comprehensive protection
  • Backup for data recovery
  • ASR for business continuity

Documentation Links:


Section 6: Network Watcher

Q6.1: What is Network Watcher?

Answer: Network Watcher provides tools to monitor, diagnose, and gain insights into Azure network health.

Key Tools:

ToolDescription
IP flow verifyTest if traffic is allowed/denied
Next hopDetermine next hop for traffic
Connection troubleshootTest connectivity between resources
NSG diagnosticsAnalyze NSG rules
Packet captureCapture network packets
Connection monitorMonitor connectivity over time
Traffic analyticsAnalyze NSG flow logs

IP Flow Verify:

bash
# Test if traffic is allowed
az network watcher test-ip-flow \
  --resource-group "Network-RG" \
  --vm "MyVM" \
  --direction Inbound \
  --protocol TCP \
  --local "10.0.0.4:80" \
  --remote "203.0.113.5:12345"

Connection Troubleshoot:

bash
# Test connectivity
az network watcher test-connectivity \
  --resource-group "Network-RG" \
  --source-resource "SourceVM" \
  --dest-resource "DestVM" \
  --dest-port 443

NSG Flow Logs:

bash
# Enable flow logs
az network watcher flow-log create \
  --resource-group "Network-RG" \
  --name "MyFlowLog" \
  --nsg "MyNSG" \
  --storage-account "mystorageaccount" \
  --enabled true \
  --retention 7

Documentation Links:


Practice Questions

Question 1

You need to be notified when a VM is deleted in your subscription. What should you configure?

A. Metric alert
B. Log alert
C. Activity log alert
D. Service health alert

Answer: C

Activity log alerts monitor subscription-level events like resource creation, modification, and deletion. VM deletion is an administrative event captured in the Activity log.


Question 2

You want to analyze failed sign-in attempts over the past week. Which tool should you use?

A. Metrics Explorer
B. Log Analytics with KQL
C. Activity Log
D. Azure Advisor

Answer: B

Log Analytics with KQL allows you to query SigninLogs table for detailed analysis of sign-in events. Metrics don't contain sign-in details.


Question 3

You need to protect VMs against regional outages with minimal data loss (RPO < 15 minutes). What should you use?

A. Azure Backup
B. Azure Site Recovery
C. VM snapshots
D. Availability Zones

Answer: B

Azure Site Recovery provides continuous replication with RPO of minutes, suitable for disaster recovery scenarios. Azure Backup has RPO of hours to days.


Question 4

Which KQL query returns the top 10 computers by average CPU usage?

A. Perf | where CounterName == "% Processor Time" | top 10 by CounterValue
B. Perf | where CounterName == "% Processor Time" | summarize avg(CounterValue) by Computer | top 10 by avg_CounterValue
C. Perf | where CounterName == "% Processor Time" | take 10
D. Perf | where CounterName == "% Processor Time" | order by CounterValue | take 10

Answer: B

You need to summarize (aggregate) by Computer to get average per computer, then use top to get the highest values.


Question 5

You need to test if a VM can receive HTTP traffic from the internet. Which Network Watcher tool should you use?

A. Connection troubleshoot
B. IP flow verify
C. Next hop
D. Packet capture

Answer: B

IP flow verify tests whether traffic is allowed or denied by NSG rules. It shows which rule allows or blocks the traffic.


Summary

Key topics for the Monitoring domain:

  1. Azure Monitor: Metrics, logs, data sources
  2. Metrics vs Logs: When to use each
  3. Activity Log: Subscription-level events
  4. Alerts: Metric, log, activity log, service health
  5. Action Groups: Notifications and automation
  6. Log Analytics: Workspace design, data collection
  7. KQL: Query syntax, common operators
  8. Azure Backup: Vaults, policies, restore options
  9. Site Recovery: Replication, failover, recovery plans
  10. Backup vs ASR: Different purposes, when to use
  11. Network Watcher: Diagnostics and troubleshooting

Released under the MIT License.