An Azure Automation account combines stored code, stored secrets and a privileged identity in one resource, so anyone who can edit a runbook can act with whatever rights that identity holds. Automation accounts often outlive the projects that created them, keep running scheduled jobs for years, and carry managed identities granted Contributor on whole subscriptions during a migration that nobody revisited. This guide shows Azure cloud and platform engineers how to secure the parts the customer controls: the identity runbooks use, who can edit and run them, credential and variable assets, webhooks, Hybrid Runbook Workers that run code on your own servers, network isolation and the logs that show misuse. For the wider Azure baseline, see the Microsoft Azure Security Guide; this page goes deeper on Automation only.
This is an independent guide from NHI Mgmt Group, based on Microsoft's public Azure Automation documentation as of November 2026. It is not sponsored or reviewed by Microsoft. Product features change, so confirm settings against Microsoft's current documentation.
Key takeaways
- The identity is the blast radius. Scope each Automation managed identity to the exact resources and actions its runbooks need, never Contributor or Owner at subscription scope.
- Runbook edit rights equal identity rights. Automation Contributor and Contributor can change runbooks that run as the account's identity, so treat those roles as privileged and put them behind PIM.
- Run As is gone; check what replaced it. Run As accounts retired on 30 September 2023; confirm no runbook still depends on one and that the managed identity did not inherit the old default Contributor role.
- Hybrid workers are servers running your cloud code. Harden and restrict access to them like any privileged host, and never install the worker on a domain controller.
- Webhook URLs are passwords. They cannot be retrieved after creation, every input is logged with the job, and only an expiry, disable or delete removes them.
What Azure Automation accounts are and why they matter
An Automation account holds runbooks (PowerShell, Python or graphical), schedules, webhooks and shared assets (credentials, certificates, connections and variables). Jobs run either in Azure's cloud sandbox or on Hybrid Runbook Workers, which are your own Windows or Linux machines in Azure, on Azure Arc-enabled servers or on premises. Runbooks authenticate to Azure with the account's managed identity.
That combination is why Automation accounts appear in persistence techniques: an attacker with write access can add a runbook with a schedule or webhook that runs indefinitely as a trusted identity, with no user sign-in to detect. Defenders should treat each account as a privileged non-human identity with its own owner, inventory entry and review cycle.
| Component | What it holds or does | Main risk | Primary control |
|---|---|---|---|
| Managed identity | Entra identity used by runbooks to call Azure and Microsoft Graph | Over-broad Azure RBAC or Graph permissions | Least-privilege role assignments at resource or resource group scope |
| Runbooks | Code that runs on a schedule, webhook or manual start | Malicious edits that act as the identity | Restrict Automation Contributor; review runbook changes |
| Credential, certificate, connection and encrypted variable assets | Secrets used by runbooks | Exposure through job output or edited runbooks | Encryption (Microsoft-managed or customer-managed keys); never print values |
| Webhooks | Token-bearing URLs that start a runbook | URL leakage starts jobs without authentication | Expiry, validation in the runbook, private endpoint |
| Hybrid Runbook Workers | Machines that run jobs locally | Host compromise or code execution on premises | Extension-based worker, host hardening, restricted admin access |
| Automation keys | Registration keys for DSC nodes and agent-based workers | Rogue worker or node registration | Prefer extension-based workers; rotate keys; limit listKeys |
Managed identities and Run As retirement
Microsoft retired Azure Automation Run As accounts, including Classic Run As accounts, on 30 September 2023. Each Run As account had registered an Entra application with a self-signed certificate that needed monthly renewal, and Microsoft's documentation notes that Run As accounts had Contributor on the subscription by default. New Automation accounts have a system-assigned managed identity enabled by default.
- Find remaining dependencies: use Microsoft's
IdentifyRunAsRunbooks.ps1script to list runbooks that still referenceAzureRunAsConnection, and check for leftover Run As app registrations and certificates in Entra. - Choose the identity type: system-assigned identities are tied to one account and deleted with it. User-assigned identities can be shared, but Microsoft states they support cloud jobs only; Hybrid Runbook Workers use a system-assigned identity. One identity per account and purpose keeps the blast radius small.
- Grant rights deliberately: Microsoft's
AssignMIRunAsRoles.ps1copies Run As roles to the managed identity, which also copies a default Contributor assignment if one was never reduced. Grant instead only what each runbook does, for example the start and stop actions on named virtual machines, or read on a single storage container. - Update code and test: replace the Run As logon with
Connect-AzAccount -Identityon a copy of the runbook, move from AzureRM to Az modules (AzureRM retired on 29 February 2024), then promote. - Clean up: delete the old Run As application and certificate once no runbook uses them, so an orphaned credential cannot be reused.
Audit the result with How to find over-privileged Azure managed identities. Managed identity design in general is covered in the Azure Managed Identities Security Guide.
Roles: who can change and run automation
Microsoft's role documentation warns that Automation Contributor can be used to access any resource the managed identity can reach. Contributor and Owner include the same Automation actions. Plan role assignment on that basis.
| Role | Can edit runbooks and assets | Can start jobs and read output | Use it for |
|---|---|---|---|
| Owner | Yes, and can manage access | Yes | Break-glass only; avoid at account scope for day-to-day work |
| Contributor | Yes, cannot manage access | Yes | Avoid for automation authors; too broad outside Automation |
| Automation Contributor | Yes, cannot manage access | Yes | Runbook authors, eligible through PIM, at account scope |
| Automation Operator | No | Yes: create, stop, suspend and resume jobs; read job output and streams | Operators who run approved runbooks |
| Automation Job Operator | No | Yes, for runbooks they can read | Combined with Runbook Operator for per-runbook control |
| Automation Runbook Operator | No | Reads runbook properties; can start a runbook when combined with Job Operator | Runbook-scope assignment |
| Reader | No | No | Inventory and audit |
- Avoid broad scopes and wildcards: Microsoft recommends granular Automation roles, avoiding subscription-level scope and wildcard actions such as
automationaccounts/*/read. - Use PIM: make Automation Contributor, Contributor and Owner eligible rather than permanent on accounts whose identity holds production rights.
- Restrict listKeys: Owner, Contributor and Automation Contributor can read Automation account keys by default; use a custom role with
Microsoft.Automation/automationAccounts/listKeys/actiononly where key access is needed. - Remember job output: Automation Operator and Job Operator can read job output, so anything a runbook prints is visible to them.
Runbook and credential asset security
- Encryption: credentials, certificates, connections and encrypted variables are encrypted by default with Microsoft-managed keys. Use customer-managed keys in Azure Key Vault where policy requires control of the key. For secrets shared with other workloads, keep them in Key Vault and have the managed identity read them at run time. See the Azure Key Vault Security Guide.
- Never print secrets: Microsoft's guidelines warn against writing credential or certificate details to job output, which lower-privilege operators can read. Credentials are removed from job streams before they reach diagnostic logs, but plain variables and custom output are not.
- Mark variables encrypted: store any sensitive value as an encrypted variable; an unencrypted variable is readable by anyone who can read the account.
- Control change: keep runbook source in a repository with review, use source control integration where it fits, and back up runbooks and assets. Treat a runbook edit outside the pipeline as a security event.
- Retire unused content: delete runbooks, schedules and assets that no longer run. Dormant runbooks with a live identity are attractive to an attacker who wants a quiet foothold.
Webhook handling
- Treat the URL as a secret: it carries a security token, anyone with it can start the runbook, and it cannot be retrieved after creation. Store it in a secrets manager and never place it in ARM template outputs, because deployment history is readable by principals with Reader.
- Set a short expiry: the portal defaults to one year. An expired webhook cannot be reactivated; you delete and recreate it, which issues a new URL. Use Disabled to stop a webhook immediately.
- Validate in the runbook: check
WebhookData(name, headers, body) and, where possible, confirm an external condition before acting. Microsoft advises against webhooks for highly sensitive runbooks without an extra validation method. - Keep sensitive data out: all webhook input values are logged with the job and visible to anyone with job access.
- Restrict the network path: use the Webhook private endpoint sub-resource, or the
GuestAndHybridManagementservice tag in NSGs or Azure Firewall.
Hybrid Runbook Workers
A Hybrid Runbook Worker turns cloud-authored code into local execution, so it extends the Automation account's trust boundary into your data centre. Microsoft directs customers to the extension-based (V2) worker, which authenticates with Entra ID and does not depend on the Log Analytics agent, and to migrate agent-based (V1) User workers. Removing a V1 worker from the portal leaves the agent on the machine, so uninstall it as well.
- Placement: never install the worker on a domain controller; Microsoft calls this out as a high-risk attack vector. Use dedicated worker machines grouped by the trust level of the systems they manage.
- Run-as account: by default the Windows extension runs jobs as Local System. Where jobs do not need that, set the worker group's Hybrid Worker credentials to a custom credential asset with only the folder permissions Microsoft lists, granted directly to the account.
- Host access: anyone with VM Contributor, run command or local admin on the worker can tamper with jobs or read what they handle. Restrict those rights and apply the same endpoint hardening, EDR and patching as for other tier-zero-adjacent servers. For Arc-connected workers see the Azure Arc-Enabled Servers Security Guide.
- Identity: the system-assigned managed identity of the worker machine is enabled when the worker is added; scope its rights as tightly as the account's.
- Lifecycle: unregister unused or unresponsive workers, keep minor extension versions on automatic upgrade (the default), and use hybrid worker custom roles for people who register workers or manage groups.
- Network: workers need outbound TCP 443 to
*.azure-automation.net; with Private Link they reach the account through the DSCAndHybridWorker endpoint.
Network isolation and private endpoints
Azure Private Link gives the account private IP addresses in your virtual network through two sub-resources: Webhook for webhook calls and DSCAndHybridWorker for hybrid workers, State Configuration and the job runtime. Resolve names through a private DNS zone named privatelink.azure-automation.net.
Setting Public network access to disabled (Network Isolation under Account Settings) means only private endpoint connections are allowed; public calls receive HTTP 401. Plan for the documented trade-offs before switching:
| Choice | Benefit | Trade-off | Fits |
|---|---|---|---|
| Public access with webhook validation | Simplest; cloud jobs and alert-triggered webhooks work | Webhook URL reachable from the internet | Low-impact runbooks, small estates |
| Private endpoints with public access enabled | Workers and internal callers use private paths | Public endpoint still exposed | Transition phase |
| Private endpoints, public access disabled | No public path to the account | Alerts cannot trigger webhooks; cloud jobs cannot reach private-endpoint resources, so jobs move to hybrid workers in a virtual network | Accounts whose identity holds production or tenant-wide rights |
Monitoring and detection
Send Automation resource logs to Log Analytics through diagnostic settings. Records arrive in the AzureDiagnostics table with ResourceProvider == "MICROSOFT.AUTOMATION", with up to 15 minutes of ingestion lag. The AuditEvent category records create, update and delete operations on runbooks, jobs and assets with the caller's object ID and app ID, but scrubs client IP and principal name; the Azure Activity log carries the caller and client IP, so use both.
| Event | Source | Why it matters |
|---|---|---|
Runbook created, updated or published (Microsoft.Automation/automationAccounts/runbooks/write) | Activity log; AuditEvent (targetResources_Resource_s Runbook) | Code change that will run as the identity; alert outside the release pipeline |
Webhook created (.../webhooks/write) | Activity log | New unauthenticated trigger; a classic persistence step |
Schedule created or linked (.../schedules/write, .../jobSchedules/write) | Activity log | Recurring execution added |
| Credential or variable changed | AuditEvent (Credential, Variables) | Secret replaced or added outside change |
Hybrid worker or worker group registered (.../hybridRunbookWorkerGroups/write) | Activity log | New machine that will execute jobs |
Role assignment to the account's identity (Microsoft.Authorization/roleAssignments/write) | Activity log | Privilege growth of the automation identity |
| Job started, failed or suspended | JobLogs (ResultType, RunbookName_s, Caller_s) | Jobs started at odd times or by unexpected callers |
| Job error and output streams | JobStreams | Errors from a tampered runbook; secrets accidentally printed |
| Managed identity sign-ins | Entra managed identity sign-in logs | Identity used against resources it does not normally touch |
Metrics that show the programme is working:
- Broad identities: number of Automation identities holding Owner, Contributor or User Access Administrator at subscription or management group scope (target zero).
- Standing editors: permanent (non-PIM) holders of Automation Contributor, Contributor or Owner on Automation accounts.
- Webhook hygiene: webhooks with expiry beyond your policy, and webhooks not triggered in 90 days.
- Untracked change: runbook writes not matched to a pipeline run or change ticket.
- Worker estate: share of hybrid workers on the extension-based platform, and workers on domain controllers (target zero).
| Framework | Reference | Relevance |
|---|---|---|
| MITRE ATT&CK | T1651 Cloud Administration Command | Abuse of cloud management services to run code on managed machines |
| MITRE ATT&CK | T1078.004 Cloud Accounts | Misuse of a valid cloud identity such as the account's managed identity |
| MITRE ATT&CK | T1098.003 Additional Cloud Roles | Granting extra roles to an automation identity |
| NIST SP 800-53 Rev 5 | AC-6, AC-2, CM-6, AU-6, SC-7 | Least privilege, account management, configuration, log review, boundary protection |
| NIST CSF 2.0 | PR.AA-05, DE.CM-01 | Access permissions managed and reviewed; networks and services monitored |
Common failure patterns
- Copying Run As roles wholesale: the migration script carried the default subscription Contributor role onto the managed identity, so the retirement changed the credential but not the privilege.
- Developers as Contributor on the account: engineers given Contributor to "fix a runbook" can now run code as an identity with production rights, with no PIM approval.
- Secrets in output: a debugging line writes a password or token to job output, readable by every operator and kept in Log Analytics.
- Long-lived webhooks in tickets and templates: URLs pasted into chat, wiki pages or template outputs remain valid for their full expiry.
- Workers on sensitive servers: a hybrid worker installed on a domain controller or management server for convenience turns any runbook author into an operator of that server.
- No AuditEvent logging: diagnostic settings were never configured, so runbook and asset changes can only be reconstructed from the Activity log, without asset names.
Practitioner checklist
- Inventory every Automation account with owner, identity, role assignments, webhooks and hybrid worker groups.
- Confirm no runbook depends on Run As and delete leftover Run As applications and certificates.
- Reduce each managed identity to the actions and scopes its runbooks need; remove subscription-scope Contributor and Owner.
- Make Automation Contributor, Contributor and Owner PIM-eligible; give operators Automation Operator or Job Operator plus Runbook Operator.
- Store secrets as encrypted assets or in Key Vault; remove any print of secrets from runbooks.
- Set short webhook expiry, validate requests in the runbook and delete unused webhooks.
- Move hybrid workers to the extension-based platform, off domain controllers, with restricted host access.
- Use private endpoints and disable public network access for accounts with high-privilege identities.
- Enable diagnostic settings for JobLogs, JobStreams and AuditEvent and alert on runbook, webhook, schedule, worker and role changes.
Standards and references
- Microsoft Learn: Best practices for security in Azure Automation
- Microsoft Learn: Migrate from Run As accounts to managed identities
- Microsoft Learn: Manage role permissions and security in Azure Automation
- Microsoft Learn: Start a runbook from a webhook
- Microsoft Learn: Deploy an extension-based Windows or Linux User Hybrid Runbook Worker
- Microsoft Learn: Use Azure Private Link to securely connect networks to Azure Automation
- Microsoft Learn: Forward Azure Automation diagnostic logs to Azure Monitor
- MITRE ATT&CK: T1651 Cloud Administration Command
Related NHI Mgmt Group resources: Microsoft Azure Security Guide · Azure Managed Identities Security Guide · Azure Logic Apps Security · Azure Security Checklist