0
0
Azurecloud~5 mins

Operational excellence pillar in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Operational excellence helps you run your cloud systems smoothly and improve them over time. It focuses on monitoring, automation, and responding quickly to problems to keep services reliable and efficient.
When you want to track how well your cloud applications are performing and spot issues early.
When you need to automate routine tasks to reduce manual work and errors.
When you want to create a culture of continuous improvement in your cloud operations.
When you need to respond quickly to incidents to minimize downtime.
When you want to document and share best practices for running your cloud environment.
Commands
This command creates a Log Analytics workspace in Azure Monitor to collect and analyze logs and metrics from your cloud resources.
Terminal
az monitor log-analytics workspace create --resource-group example-rg --workspace-name example-workspace --location eastus
Expected OutputExpected
{ "customerId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "location": "eastus", "name": "example-workspace", "resourceGroup": "example-rg", "sku": { "name": "PerGB2018" }, "type": "Microsoft.OperationalInsights/workspaces" }
--resource-group - Specifies the Azure resource group to create the workspace in
--workspace-name - Names the Log Analytics workspace
--location - Sets the Azure region for the workspace
This command enables diagnostic logs and metrics for a virtual machine and sends them to the Log Analytics workspace for monitoring.
Terminal
az monitor diagnostic-settings create --resource /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.Compute/virtualMachines/example-vm --name example-diagnostics --workspace example-workspace --logs '[{"category": "Administrative", "enabled": true}]' --metrics '[{"category": "AllMetrics", "enabled": true}]'
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.Compute/virtualMachines/example-vm/providers/microsoft.insights/diagnosticSettings/example-diagnostics", "name": "example-diagnostics", "type": "Microsoft.Insights/diagnosticSettings" }
--resource - Specifies the resource to monitor
--workspace - Sends logs and metrics to this Log Analytics workspace
--logs - Enables specific log categories
This command creates an alert rule that triggers when the average CPU usage of the virtual machine goes above 80%, helping you respond quickly to performance issues.
Terminal
az monitor metrics alert create --name example-alert --resource-group example-rg --scopes /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.Compute/virtualMachines/example-vm --condition "avg Percentage CPU > 80" --description "Alert when CPU usage is high" --action example-action-group
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/microsoft.insights/metricAlerts/example-alert", "name": "example-alert", "type": "Microsoft.Insights/metricAlerts" }
--scopes - Defines which resource the alert monitors
--condition - Sets the metric condition that triggers the alert
--action - Specifies the action group to notify when alert fires
This command creates an action group that defines who gets notified when alerts happen, such as sending emails to the operations team.
Terminal
az monitor action-group create --name example-action-group --resource-group example-rg --short-name exag --email-receivers name=OpsTeam email=ops@example.com
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/microsoft.insights/actionGroups/example-action-group", "name": "example-action-group", "type": "Microsoft.Insights/actionGroups" }
--short-name - Sets a short name for the action group
--email-receivers - Defines email recipients for alerts
Key Concept

If you remember nothing else from this pattern, remember: monitoring and automated alerts help you catch and fix problems before they affect users.

Common Mistakes
Not linking diagnostic settings to a Log Analytics workspace
Without linking, logs and metrics are not collected centrally, so you cannot analyze or alert on them.
Always specify the --workspace flag when creating diagnostic settings to send data to a Log Analytics workspace.
Creating alerts without action groups
Alerts will trigger but no one will be notified, so issues may go unnoticed.
Create and attach an action group to alerts to ensure notifications reach the right people.
Using vague alert conditions
Alerts may fire too often or miss important issues, causing alert fatigue or blind spots.
Define clear, specific metric conditions that reflect real operational thresholds.
Summary
Create a Log Analytics workspace to collect monitoring data.
Enable diagnostic settings on resources to send logs and metrics to the workspace.
Set up alerts with clear conditions and link them to action groups for notifications.
Use these tools to monitor your cloud environment and respond quickly to issues.