Skip to content

Azure Automation Runbooks

Exported from aa-eshars-prod (and related accounts) in rg-eshars-prod. Scripts live in eshars-ops/scripts/azure-runbooks/.

Automation Accounts

Current (v2, Central US) — see the v2 page for detail:

AccountResource groupPurpose
aa-eshars-nonprod-cusrg-eshars-ops-nonprod-cusSelf-service restore/seed for dev, qa, regression
aa-eshars-prod-cusrg-eshars-ops-prod-cusSelf-service restore for uat, training, prod

Legacy (v1, East US 2) — the rest of this page:

AccountRunbooksPurpose
aa-eshars-prod25Database lifecycle — copies, scrubs, exports, monitoring
aa-eshars-prod-azmodule1SQL database scaling
JobLogsCleanup5Purge old Quartz job log records (per environment)
PeriodicCleanup5General application data cleanup (per environment)

Infrastructure Reference

SQL Servers

ServerHostsResource Group
db-eshars-prodProduction, UAT, Regression databasesrg-eshars-prod
db-eshars-nonprodQA, Training databasesrg-eshars-nonprod
db-eshars-developeraccessScrubbed dev copiesrg-eshars-nonprod

Storage Accounts

AccountContainerPurpose
sahisddatabackuphisdbackupsMonthly exports
sahisddatabackuphisdbackups-weeklyWeekly exports (13-day retention)
sahisddatabackuphisd-prod-snapshots-iepUAT/fiscal-year snapshots
esharsdbstoragedb-storageOn-demand developer .bacpac files

Runbook Catalog

Database Copy Operations

RunbookSourceTargetNotes
aa-eshars-prod-to-prodtestproddeveloperaccess/prodtestMain DB for dev testing
aa-eshars-prod-audit-to-prodtest-auditprod-auditdeveloperaccess/prodtest-auditCopies at S3, scales to P2
aa-eshars-prod-to-regression-auditprod-auditnonprod/regression-audit01Legacy RunAs auth
aa-eshars-prod-to-regression-logdb-log-prodprod/regression-log01Same-server copy
aa-qa-to-regressionnonprod/qaprod/regression-dsCross-server copy
ar-eshars-regressiondb-copyprodprod/regression-dsSame-server copy
ar-eshars-uatdb-copyprodprod/uat-dataSame-server copy
ar-eshars-database-copy(parameterized)(parameterized)Generic copy with overwrite flag

PII Scrub & Developer Database Provisioning

These runbooks copy production data to a developer-accessible server, scrub all PII, and export a .bacpac. See PII Scrub Pipeline for full details.

RunbookStatusAuthNotes
ar-eshars-database-scrubCurrentManaged IdentityAuto-cleanup after export. Runs on Hybrid Worker run-bacpacs-group
ar-eshars-proddb-copy-and-scrub-for-devsLegacyManaged Identity + RunAsHardcoded storage key — do not use
Test-latestprodcopyto-sqldeveloperaccessLegacyRunAsHardcoded storage key — do not use
ar-eshars-drop-db-eshars-backupscrubLegacyRunAsMisleading name — actually a full copy+scrub, not a drop
aa-eshars-prod-to-qa-scrubActiveRunAsProd → QA/Regression with environment-aware scrub
ar-eshars-qa-copy-for-devActiveManaged IdentityQA → dev; audit-table-only scrub

Backup & Export

See Backup & Export Schedule for schedule, retention, and storage layout.

RunbookDatabasesStorageRetention
ar-eshars-weekly-db-exportprod, prod-audithisdbackups-weekly13 days
ar-eshars-weekly-logdb-exportdb-log-prodhisdbackups-weekly13 days (cleanup commented out)
ar-eshars-monthly-db-exportprod, prod-audit, db-log-prodhisdbackupsNone (overwrites)
ar-eshars-uat-db-fiscal-updateprod, prod-audit, db-log-prodhisd-prod-snapshots-iep7 years
ar-eshars-uat-db-bacpac-updateuat-data, uat-audit, uat-loghisd-prod-snapshots-iepNone

Restore / Import

RunbookSourceTargetNotes
ar-eshars-db-restore-from-bacpachisd-prod-snapshots-iep/*.bacpacprod/uat-dataImports at P4 tier. Hardcoded bacpac filename
ar-eshars-uat-fiscal-update-testhisd-prod-snapshots-iep/*.bacpacprod/uat-dataDrops existing UAT, imports at P6

Monitoring & Utilities

RunbookPurpose
ar-eshars-elasped-time-prodMeasures prod DB query latency, posts to Slack #proj-eshars-devops
ar-eshars-elasped-time-nonprodMeasures QA DB query latency, posts to Slack #proj-eshars-devops
ar-eshars-clear-logsDeletes ELMAH error logs older than 31 days. Parameterized (server, DB, creds)
TriggerRnSFlowRuns ruby main.rb on vm-rns-prod via Invoke-AzVMRunCommand
ScaleAzureSQLDBScales a SQL DB to a specified DTU tier (Basic, S0–S12, P1–P15)
eSHARS-JobScheduler-OOM-RestartTriggered by Azure Monitor alert on Event 1026. Restarts eSharsJobScheduler_PRODJOB on vm-jobscheduler-prod via Hybrid Worker, then sends Teams alert

Scheduled Cleanup (Per-Environment)

JobLogsCleanup — Purges old Quartz job log records

Calls sp_CleanupOldJobData on each environment’s log database. Server/database names are hardcoded in each script.

VariantServerDatabaseAuth
CleanRecords_PRODdb-eshars-proddb-log-prodAutomationPSCredential
CleanRecords_QAdb-eshars-nonproddb-log-qaAutomationPSCredential
CleanRecords_Regressiondb-eshars-proddb-eshars-regression-log01AutomationPSCredential
CleanRecords_Trainingdb-eshars-nonproddb-log-trnAutomationPSCredential
CleanRecords_UATdb-eshars-proddb-eshars-uat-logAutomationPSCredential

PeriodicCleanup — General application data cleanup

Calls sp_CleanupData on each environment’s main application database. Server/database names pulled from Azure Automation Variables.

VariantServer VariableDatabase Variable
CleanRecords_PRODProdServerPROD_DB
CleanRecords_QANonProdServerQA_DB
CleanRecords_RegressionProdServerRegression_DB
CleanRecords_TrainingNonProdServerTraining_DB
CleanRecords_UATProdServerUAT_DB

Known Issues

  1. Misleading filenamear-eshars-drop-db-eshars-backupscrub.ps1 is actually a full copy+scrub+export pipeline, not a simple database drop.
  2. Hardcoded datesar-eshars-uat-db-bacpac-update and ar-eshars-uat-db-fiscal-update have hardcoded date suffixes. Manual update required each run.
  3. Legacy auth — ~50% of runbooks still use AzureRunAsConnection (deprecated). Migration to Managed Identity is partially complete (see below).
  4. Weekly log export retention disabledar-eshars-weekly-logdb-export has the blob cleanup line commented out.

Auth Migration Status

PatternRunbooksStatus
Connect-AzAccount -Identity (Managed Identity)~13Current
AzureRunAsConnection (Service Principal)~12Deprecated — migrate
Get-AutomationPSCredential (SQL auth only)10Expected for SQL connections