Skip to main content

Automation & Scheduling

Automation Landscape — Know Which Tool When

Automation Tool Landscape
🛠️
SQL Agent
Built-in job scheduler for MI & VM. T-SQL, PowerShell, SSIS steps. Jobs stored in msdb.
🎯
Elastic Jobs
Schedule T-SQL across multiple Azure SQL Databases. Target groups define scope.
⚙️
Azure Automation
PowerShell/Python runbooks for infrastructure tasks. Scale DBs on schedule.
Azure Functions
Event-driven code: Timer triggers, HTTP, Queue, Event Grid. Serverless + auto-scale.
🔗
Logic Apps
No-code visual workflows with 400+ connectors. Approvals, Teams, Email, ServiceNow.

Decision Matrix (Exam Favorite)

FeatureSQL AgentElastic JobsAzure AutomationAzure FunctionsLogic Apps
Available on SQL DB
Available on MI
Available on VM
Runs T-SQLVia scriptVia SDKVia connector
Multi-DB targetingVia scriptVia codeVia connector
PowerShell
Schedule✅ (Timer)✅ (Recurrence)
Event-drivenVia webhook
No code
🎯 Exam Focus

The simplest exam rule: SQL Agent → MI & VM. Elastic Jobs → Azure SQL Database. If the question says "Azure SQL Database" + "schedule T-SQL" → Elastic Jobs. If it says "scale the database tier on a schedule" → Azure Automation.

SQL Agent Jobs (MI & VM)

The direct equivalent of Oracle DBMS_SCHEDULER. Fully supported on MI and VM.

Architecture

SQL Agent Job Architecture
📅
Jobs & Schedules
Jobs contain multiple steps with success/failure flow. Schedules define when jobs run. All stored in msdb.
🛠️
Step Types
T-SQL, PowerShell, SSIS, SSAS, Replication. Each step can branch on success or failure.

Key exam facts:

  • Jobs, steps, schedules, alerts stored in msdb database
  • Jobs can have multiple steps with success/failure flow control
  • Steps support: T-SQL, PowerShell, SSIS, SSAS, Replication
  • MI Failover Groups don't replicate msdb → agent jobs must be manually synced to secondary
🏢 Real-World DBA Note

Oracle DBA parallel: SQL Agent = DBMS_SCHEDULER + DBMS_JOB. The concepts are identical: jobs, steps (programs), schedules, chains (multi-step with flow control), notifications (alerts). The main difference: SQL Agent uses msdb to store metadata; Oracle uses SYS.SCHEDULER$_* tables.

Elastic Jobs (Azure SQL Database)

Since SQL Agent isn't available in Azure SQL Database, Elastic Jobs fills the gap.

Architecture

Elastic Jobs Architecture
🧠
Job Agent
Runs in a dedicated Azure SQL Database. Manages job definitions and execution.
🎯
Target Group
Defines which databases to run against: entire server, elastic pool, or specific DBs.
▶️
Job Step
T-SQL command executed on each target database. Uses stored credential for auth.

Key concepts:

  • Job Agent — manages jobs, requires its own database
  • Target Group — defines which databases to run against (server, pool, or individual DBs)
  • Job Step — T-SQL command to execute
  • Credential — authentication to connect to target databases
🎯 Exam Focus

Elastic Jobs need a dedicated database for the job agent. Target groups can be: an entire server (all DBs), an elastic pool, or specific individual databases. The job agent connects to each target and runs the T-SQL step.

Azure Automation — Infrastructure Scheduling

Best for PowerShell/Python operations on Azure resources (not T-SQL on databases).

Common Use Cases

ScenarioOracle EquivalentHow It Works
Scale DB up for business hours, down at nightcron + shell scriptScheduled runbook calls Set-AzSqlDatabase
Patch managementOPatch scriptsUpdate Management built-in
Automated failover testingData Guard switchover scriptRunbook calls failover group commands
Resource cleanupCustom cleanup scriptsScheduled runbook deletes old resources

Key Architecture

Azure Automation Runbook Flow
Trigger
Schedule (time-based)
Webhook (event-based)
Azure Monitor alert
🤖
Runbook Executes
PowerShell or Python script
Uses Managed Identity for auth (no secrets)
⚙️
Azure Action
Set-AzSqlDatabase (scale tier)
Start/Stop VMs, resource cleanup
📧
Notification
Output logged to Automation account
Optional webhook to Teams/email
⚠️ Watch Out

Azure Automation runbooks use Managed Identity (or Run-As accounts, now deprecated). Always use System-assigned Managed Identity with RBAC roles. Never store secrets in the runbook code.

Azure Functions — Event-Driven Automation

Best for code-based tasks triggered by events or timers.

TriggerUse CaseExample
TimerScheduled maintenanceUpdate stats daily at 2am
HTTPOn-demand actionTrigger database refresh via API
QueueAsync processingProcess new data import messages
Event GridReact to Azure eventsAlert when SQL threat detected
🏢 Real-World DBA Note

Oracle DBA parallel: Azure Functions (Timer Trigger) = the modern replacement for cron + shell scripts. Serverless (no VM to manage), auto-scaling, pay-per-execution. Your AzureDigest project already uses this pattern!

Logic Apps — No-Code Workflows

Best for multi-step workflows with approvals and integrations.

Logic Apps Workflow
🔔
Trigger
Recurrence schedule
HTTP request, Event Grid, queue message
🗄️
Get Data
SQL connector: run query or stored proc
400+ connectors for any service
🧠
Logic & Conditions
If/else branches, loops, variables
Approval steps (human-in-the-loop)
📨
Action
Send Teams message, email, or ticket
Update database, call API, trigger function

When to use Logic Apps over Functions:

  • You need visual workflow design (non-developers in the team)
  • You need built-in connectors (Email, Teams, ServiceNow, SAP)
  • You need approval workflows (human-in-the-loop)
  • You DON'T need custom code logic

Flashcards

Which Azure SQL deployment supports SQL Agent?
Click to reveal answer
SQL Managed Instance and SQL Server on VMs. NOT Azure SQL Database.
1 / 5

Quiz

Q1/3
0 correct
You have 50 Azure SQL Databases and need to run sp_updatestats on all of them weekly. What should you use?