Study guide
12.3 Azure Automation Runbooks, Alerts, and Troubleshooting Automated Tasks
DP-300: Administering Microsoft Azure SQL Solutions Exam
Track your progress as you read
Finished sections get a check mark.
1 Introduction & Exam Overview
1.1 Current DP-300 Exam Facts 1.2 Skills Outline and Domain Weights 1.3 Study Strategy and Official Resources
2 Planning and Deploying Azure SQL Solutions
2.1 Choosing and Deploying Azure SQL Database Offerings 2.2 Automated Deployment, Azure Arc, and SQL Database in Microsoft Fabric 2.3 Table Partitioning and Sharding Strategy 2.4 Hybrid SQL Server and IaaS Patching
3 Configuring Resources for Scale and Performance
3.1 Configuring Azure SQL Database for Scale and Performance 3.2 Configuring Azure SQL Managed Instance for Scale and Performance 3.3 Configuring SQL Server on Azure VMs for Scale and Performance 3.4 Configuring Table Partitioning and Data Compression
4 Planning and Implementing a Migration Strategy
4.1 Evaluating Migration Requirements and Strategies 4.2 Implementing Online, Offline, and Azure Migrations 4.3 Migrating Between Azure SQL Services and Troubleshooting
5 Configuring Database Authentication and Authorization
5.1 Microsoft Entra ID Authentication for Azure SQL 5.2 Authentication for SQL on Azure VMs and Managed Instance; Troubleshooting 5.3 Security Principals and Entra-Backed Users 5.4 Permissions, Least Privilege, and T-SQL Management
6 Implementing Security for Data at Rest and in Transit
6.1 Transparent Data Encryption and Object-Level Encryption 6.2 Always Encrypted and VBS Enclaves 6.3 Firewall Rules, Private Links, and Service Endpoints
7 Implementing Compliance Controls for Sensitive Data
7.1 Data Classification and Server/Database Auditing 7.2 Change Data Tracking and Dynamic Data Masking 7.3 Row-Level Security and Ledger in Azure SQL
8 Monitoring Resource Activity and Performance
8.1 Operational Baselines and Performance Metric Sources 8.2 Interpreting Metrics and Configuring Activity Monitoring 8.3 Monitoring with Database Watcher (Preview) 8.4 Monitoring with Extended Events
9 Monitoring and Optimizing Query Performance
9.1 Configuring and Monitoring with Query Store 9.2 Session Blocking and Dynamic Management Views 9.3 Index Changes and Execution Plan Review 9.4 Query Construct Modifications and Intelligent Insights
10 Configuring Database Solutions for Optimal Performance
10.1 Index, Statistics, and Integrity Maintenance 10.2 Automatic Tuning and Database-Scoped Configuration 10.3 Server Settings and Resource Governor 10.4 Compute/Storage Scaling and Intelligent Query Processing
11 Creating and Managing SQL Server Agent Jobs
11.1 Schedules for Regular Maintenance Jobs 11.2 Job Alerts, Notifications, and Agent Troubleshooting 11.3 Automating Deployment with ARM and Bicep Templates
12 Automating Deployments and Database Tasks in Azure
12.1 Azure PowerShell, Azure CLI, and Deployment Monitoring 12.2 Elastic Jobs for Cross-Database Automation 12.3 Azure Automation Runbooks, Alerts, and Troubleshooting Automated Tasks
13 Planning an HA/DR Strategy and Backup and Restore
13.1 Recommending HA/DR Strategy from RPO and RTO 13.2 Hybrid and Azure-Specific HA/DR Solutions and Testing 13.3 Backup and Restore Strategy with Native Tools 13.4 Point-in-Time Restore and Recovery Operations
14 Configuring HA/DR: Long-Term Retention, Geo-Replication, and Failover Groups
14.1 Long-Term Retention, T-SQL Backup/Restore, and Cloud Storage 14.2 Active Geo-Replication 14.3 Failover Groups
15 Advanced HA/DR: Availability Groups, FCIs, Log Shipping, and Troubleshooting
15.1 Always On Availability Groups on SQL Managed Instance and Azure VMs 15.2 Always On Failover Cluster Instances and Log Shipping 15.3 Monitoring and Troubleshooting HA/DR Solutions
12.3 Azure Automation Runbooks, Alerts, and Troubleshooting Automated Tasks
Key Takeaways Explain This Topic AI
Azure Automation schedules PowerShell, Python, and graphical runbooks; the Automation account stores runbooks, credentials, variables, schedules, and modules, and runs on Azure workers or on-premises via Hybrid Runbook Worker
Authenticate runbooks to Azure SQL with a system-assigned managed identity wherever possible - it eliminates secret rotation; service principals and stored credentials are the legacy alternative
Configure alerts on automated tasks with metric alerts (numeric thresholds) and activity log alerts (control-plane events like a failed runbook job); action groups route notifications to email, webhook, Logic App, or Functions
Common runbook failures are missing managed-identity permissions, private endpoint/firewall blocking the worker, timeouts, and stale module versions; diagnose via job streams and the activity log
Choose Elastic Jobs for T-SQL across many Azure SQL Databases, SQL Server Agent for T-SQL/SSIS on MI or VM, and Azure Automation for non-T-SQL orchestration and cross-service workflows
Last updated: August 2026
Azure Automation: The Platform for Scheduled Tasks
Where Elastic Jobs handle T-SQL across many databases, Azure Automation is the general-purpose scheduler and orchestrator for any script in Azure. It is the right tool when the automation is not a single T-SQL batch - for example, calling Azure REST APIs, restarting a VM, copying blobs, rotating keys in Key Vault, or orchestrating a sequence of steps that touch more than one service. The DP-300 exam expects you to know what lives in an Automation account, how runbooks authenticate to SQL, and how to alert and troubleshoot.
An Azure Automation account is the container for everything automation-related. Inside it you find:
- Asset Purpose
- Runbooks The scripts themselves - PowerShell, Python, or graphical (PowerShell Workflow / graphical authoring)
- Credentials Username/password pairs stored securely
- Certificates Certificates for service-principal auth
- Variables Named values (string, int, boolean, datetime) reused across runbooks; can be encrypted
- Schedules Time-based triggers (one-time or recurring)
- Modules PowerShell modules (Az.Accounts, Az.Sql, SqlServer, etc.) available to runbooks
- Connections Pre-defined connection objects (Azure classic, ARM)
A runbook is a single script. Runbook types include:
PowerShell - native PowerShell script; the most common.
Python - Python 3 script; useful for teams with Python skills.
Graphical - a visual flow designed in the portal; good for low-code orchestration and approval workflows.
PowerShell Workflow - the older workflow-based type that supports checkpoints and parallelism; rarely chosen for new runbooks.
Hybrid Runbook Worker
By default, runbooks run on an Azure-hosted sandbox worker, which has outbound internet access but cannot reach on-premises resources or anything behind a private endpoint without extra configuration. A Hybrid Runbook Worker is a VM (Azure VM or on-premises) with the Hybrid Worker extension installed; runbooks targeted to a hybrid worker run on that VM and can reach whatever that VM can reach. The exam scenario that says "run a script that connects to an on-premises SQL Server" or "run a script against a database behind a private endpoint" points to a hybrid worker - the Azure sandbox cannot reach either.
Authenticating a Runbook to Azure SQL
The cleanest modern pattern is a system-assigned managed identity on the Automation account. The runbook acquires a token with Connect-AzAccount -Identity and uses it to run Azure cmdlets or to obtain a SQL access token. The SQL-side work is to provision the managed identity as a database user: CREATE USER [myAutomationAccount] FROM EXTERNAL PROVIDER;
- ALTER ROLE db_datareader ADD MEMBER [myAutomationAccount];
- - grant whatever the runbook needs
Then in the runbook, authenticate with the managed identity, acquire a token for https://database.windows.net , and connect with Invoke-Sqlcmd (from the SqlServer PowerShell module) using the access token: Connect-AzAccount -Identity
- $token = (Get-AzAccessToken -ResourceUrl 'https://database.windows.net').Token
- Invoke-Sqlcmd -ServerInstance tcp:sql-prod.database.windows.net,1433 `
- Database SalesDB -AccessToken $token -Query 'SELECT @@VERSION'
The legacy pattern is an Automation Credential asset (username + password for a SQL login) or a service principal with a stored secret. Both still work, but the exam prefers managed identities because they eliminate secret rotation - a point worth citing explicitly in scenario answers.
Schedules and Variables
A schedule is a recurring or one-time trigger you link to a runbook with Register-AzAutomationScheduledRunbook (PowerShell) or via the portal. You can link multiple runbooks to one schedule, and a runbook can be linked to multiple schedules with different parameter sets. Variables are how you share configuration (server name, database name, retention days) across runbooks without editing scripts; mark sensitive values as encrypted when stored.
Alerts and Notifications on Database Tasks
DP-300 explicitly tests configure alerts and notifications on database tasks . Azure has two alert types that matter for automation:
Metric alerts fire on numeric thresholds. For Azure SQL Database, useful metrics include cpu_percent , storage_percent , deadlock , connection_successful (and its failed counterpart), and tempdb_data_file_size_percent . You set a threshold (e.g., cpu_percent > 80 for 5 minutes), an evaluation frequency, and an action group .
Activity log alerts fire on control-plane events - resource write operations, service health, recommendations, and (critically for this objective) Automation job status . You can alert whenever a runbook job fails ( Job status = Failed) or whenever a specific runbook completes.
An action group is the reusable delivery layer: a named set of one or more actions that fire when an alert triggers. Supported action types:
- Action What it does
- Email / SMS / push Send a notification to a person or distribution list
- Webhook POST a JSON payload to an HTTP endpoint
- Azure Function Invoke a function (custom code)
- Logic App Trigger a Logic App workflow (approval, ticket creation, Teams post)
- Automation runbook Kick off a remediation runbook
- ITSM Create a ticket in a connected ITSM tool (ServiceNow, etc.)
The pattern the exam rewards: create one action group per notification persona (e.g., DBA-on-call, ops-team-channel) and reuse it across multiple alerts, rather than defining ad-hoc recipients on every alert. Metric alerts on cpu_percent and storage_percent with a single DBA action group cover most day-to-day Azure SQL alerting.
Monitoring Automation Jobs
Every runbook execution is a job . You inspect jobs through:
Job streams - PowerShell output, error, warning, and verbose streams captured per job. Get-AzAutomationJobOutput and Get-AzAutomationJobStream return the streams; in the portal, the job page shows them inline.
Job status - New, Running, Completed, Failed, Stopped, Suspended. Get-AzAutomationJob -Status Failed lists recent failures.
Activity log - every Automation job write is recorded, so activity-log alerts on job status are the canonical way to alert on automation failures.
A robust pattern: a runbook wraps its real work in try/catch, writes a structured error to the verbose stream, and lets the job status reflect success/failure so the activity-log alert fires only on real failures (not on handled warnings).