← All articles

Technical insight

Azure Automation and Storage security - two ways to keep your runbooks working

Choose between private Storage access with a Hybrid Runbook Worker and a hardened public endpoint for Azure Automation cloud sandbox runbooks.

An Azure Automation runbook can authenticate to Azure Storage with a managed identity and still be denied access after the storage account is hardened. That can be surprising, because the identity has the correct Azure role and the same request succeeds from a developer workstation.

The reason is that authentication and network access are separate checks. A managed identity proves who is making the request. It does not make a request originate from an allowed network.

The limitation

A normal Automation job runs in an Azure sandbox. Microsoft assigns a shared worker and you cannot choose the worker, its virtual network, or a stable outbound address.

When you enable the Storage firewall, traffic from that sandbox is blocked. Microsoft explicitly documents that this also applies when the Allow trusted Microsoft services to access this storage account exception is enabled. Azure Automation is not in the Storage trusted-services list.

This means the following controls do not solve the network problem:

  • A system-assigned or user-assigned managed identity.
  • A Storage Blob Data Contributor or more restrictive data-plane role.
  • A storage account key or SAS token.
  • The trusted Microsoft services exception.

Those controls address authorization. The request must still pass the storage account’s firewall before Storage evaluates the token or SAS.

Public endpoint does not have to mean open to the internet

The Azure portal offers several distinct Storage networking configurations:

  1. Public network access disabled
    The public endpoint rejects all traffic. Access is possible only through a private endpoint.
  2. Enabled from selected networks
    The public endpoint remains available, but the default is deny and only configured virtual networks, IP ranges, resource instances, or exceptions are allowed.
  3. Enabled from all networks
    The storage account’s public endpoint accepts traffic from any network, subject to authorization.

A cloud sandbox runbook needs a permitted route to the public endpoint. Restricting the firewall can therefore break it, and changing the setting to Enabled from all networks is not an acceptable workaround when public access must be removed.

Even an IP allow list is not a reliable network design for the shared sandbox because you do not control its worker or outbound addresses. Resource instance network rules and the trusted-services exception are not an Azure Automation bypass.

There are two practical choices: move execution into your network and disable public access, or retain the cloud sandbox and harden an endpoint that remains reachable from all networks. Both use Azure Automation; the difference is where the runbook executes and which network controls are possible.

Solution 1: use a Hybrid Runbook Worker and private Storage access

To disable Storage public network access, run the jobs on an extension-based Hybrid Runbook Worker in a network that can reach Storage privately.

For an Azure environment, the worker can be an Azure virtual machine connected to a virtual network. For an on-premises or other cloud environment, it can be an Azure Arc-enabled server. Extension-based Hybrid Runbook Workers are the supported implementation; the older agent-based worker is retired.

A typical Azure design is:

Azure Automation
  |  outbound job polling over HTTPS
  v
Hybrid Runbook Worker VM in an Azure virtual network
  |
  +-- Private DNS: <account>.blob.core.windows.net
  |
  +-- Private endpoint
        |
        v
Azure Storage -- public network access disabled

The Automation account still stores and manages the runbooks and job scheduling. The script executes on the Hybrid Runbook Worker, so its network path is the worker’s path.

1. Deploy the worker

Add an extension-based user Hybrid Runbook Worker to a Windows or Linux virtual machine in the target virtual network. Put two workers in a group if the workload requires high availability; Azure Automation distributes jobs among healthy workers and you select the group, not an individual machine, when starting the job.

The worker needs outbound HTTPS access on port 443 to Azure Automation. Use the GuestAndHybridManagement service tag and the regional DNS records where the network team requires a restricted allow list.

2. Give the worker a private route to Storage

Create a Storage private endpoint in the worker’s virtual network, or in a network connected to it. Create the endpoint for each Storage service the runbook uses:

  • blob for Blob Storage
  • dfs and blob for Azure Data Lake Storage Gen2
  • queue for Queue Storage
  • table for Table Storage
  • file for Azure Files

Link the corresponding private DNS zones to the virtual network, or configure the organisation’s DNS to return the private endpoint address. The runbook should continue to use the normal storage endpoint, such as <account>.blob.core.windows.net; it should not use a privatelink URL directly.

A virtual network service endpoint is another Microsoft-supported option. It allows the worker subnet to reach Storage’s public endpoint without opening it to all networks. Choose private endpoints when the requirement is to disable public network access completely.

3. Disable public network access

After validating private DNS and connectivity from the worker, set Storage Public network access to Disabled. Enabling a private endpoint alone does not automatically close the public endpoint.

From inside the worker virtual network, the following name resolution should return a private address rather than the Storage public endpoint:

Resolve-DnsName `
  -Name "<storage-account>.blob.core.windows.net" `
  -Type A

If the DNS result still points to the public endpoint, fix DNS before disabling public access.

4. Authorize the identity separately

Network access only creates a path. The executing identity still needs a Storage data-plane role.

Choose the lowest role and scope that meet the runbook’s requirements, for example:

  • Storage Blob Data Reader for reads.
  • Storage Blob Data Contributor for read and write operations.
  • A role scoped to a specific container when practical, instead of the whole account.

An important Hybrid Worker detail is that managed identity selection is different from the cloud sandbox. Depending on the Automation account and worker configuration, a runbook can use the Automation account’s system-assigned identity or the identity attached to an Azure VM or Arc-enabled worker. Microsoft documents that an Automation account user-assigned managed identity cannot be used on a Hybrid Runbook Worker. Enabling an Automation account managed identity also changes which identity is available to jobs on the worker.

Verify which identity Connect-AzAccount -Identity resolves to in the runbook instead of assuming it is the identity you see on the Automation account.

Solution 2: keep the cloud sandbox and harden the public endpoint

If running in the Azure Automation cloud sandbox is more important than a private-only Storage account, keep the public endpoint enabled from all networks and use identity, authorization, transport security, and monitoring to reduce the risk.

This is a security trade-off, not the equivalent of a private endpoint. The endpoint remains reachable from any network; a stolen credential or an overly permissive role could be used from outside your environment. Do not use this option if policy requires public network access to be disabled or restricted to selected networks.

1. Configure public network access deliberately

In the storage account’s Networking settings, select Enabled from all networks. This permits network connections to the public endpoint; it does not automatically make blob data anonymously readable. The Storage firewall cannot distinguish your sandbox from other networks in this configuration.

Do not assume that the trusted-services exception, a resource instance rule, or a list of observed sandbox IP addresses will restrict access to your Automation account. Microsoft documents that the Storage firewall blocks Automation cloud sandbox runbooks even with the trusted-services exception enabled.

2. Require managed identity and least-privilege data access

Enable a managed identity on the Automation account and assign it only the Storage data permissions the runbook needs. For example, assign Storage Blob Data Reader for reading or Storage Blob Data Contributor if the runbook must write or delete blobs. Scope the assignment to the specific container where practical. Roles are cumulative, so also review inherited assignments.

Use the identity to authenticate in the runbook and create the Storage context with -UseConnectedAccount, as shown in the example below. Do not put account keys, connection strings, or SAS tokens in the script. Restrict who can edit or publish runbooks, change role assignments, or manage the Automation account, because these permissions can affect what the identity can access.

3. Disable anonymous access and review Shared Key

In the storage account configuration, disallow anonymous Blob access at the account level. This prevents anonymous reads of blobs and containers even if an individual container was previously configured for public access. Check for existing anonymous consumers before changing the setting.

Where every consumer supports it, also disallow Shared Key authorization. Inventory existing clients, account keys, and SAS usage first: account-key requests, account SAS, and service SAS will stop working. Blob user delegation SAS is authorized with Microsoft Entra ID and can still work. Some services, tools, and Azure Files workloads have compatibility requirements, so test all consumers before making this account-wide change.

If Shared Key cannot yet be disabled, restrict who can list or regenerate account keys, protect existing keys, and plan a migration. Disabling Shared Key does not itself block anonymous blob access: configure both settings independently.

4. Require encrypted connections and monitor access

Require secure transfer and set the minimum TLS version to at least TLS 1.2 for Blob, Queue, Table, and Data Lake Storage requests. Check client compatibility and Azure Files-specific requirements before changing account-wide settings.

Enable diagnostic settings for the Storage services the runbook uses, including read, write, and delete logs as appropriate. Send them to a monitored destination and alert on unexpected access or authorization failures. Review who can modify Storage networking and authorization settings, and consider a dedicated storage account for this workload to reduce the impact on unrelated applications.

5. Verify the controls

Run the published runbook in the Azure sandbox and confirm the intended read or write succeeds. Then verify that an anonymous blob request and a request from a test identity without a data role are denied. If Shared Key is disabled, verify that a key-authorized request is also denied and that other legitimate consumers still work. Check Storage logs and Automation job output for the expected results.

These checks validate authorization, not network isolation: a properly authorized caller can still reach the public endpoint from another network.

Example: read blobs with managed identity

The following PowerShell runbook works with either solution when the selected identity has the required data role and network access. Import Az.Accounts and Az.Storage into the Automation runtime environment for sandbox jobs, or install the required modules on each Hybrid Worker. Replace the placeholders before running it.

$ErrorActionPreference = "Stop"

Disable-AzContextAutosave -Scope Process

Connect-AzAccount -Identity | Out-Null
$storageContext = New-AzStorageContext `
    -StorageAccountName "<storage-account>" `
    -UseConnectedAccount `
    -ErrorAction Stop

Get-AzStorageBlob `
    -Container "<container>" `
    -Context $storageContext |
    Select-Object Name, Length, LastModified

The same code uses the normal Storage endpoint in both cases. With solution 1, private DNS and routing direct the worker to a private endpoint. With solution 2, the sandbox connects to the public endpoint. In both cases Microsoft Entra ID and Azure RBAC authorize the data operation.

Private access migration checklist

Before starting the change:

  1. Confirm whether the runbook really needs the cloud sandbox. If it does, a fully private Storage account is incompatible with the current execution environment.
  2. Inventory the Storage services used by the script and create the required private endpoints.
  3. Configure private DNS, including on-premises forwarding when the worker is outside Azure.
  4. Deploy at least two Hybrid Runbook Workers for workloads that need availability.
  5. Restrict outbound traffic without blocking the Automation service endpoints.
  6. Assign a least-privilege Storage data role to the exact managed identity used by the job.
  7. Test the runbook from the Hybrid Worker group, not only in the Automation editor or cloud test pane.
  8. Verify the result in Storage diagnostic logs.
  9. Disable public network access only after the private path is proven.

Which solution should you choose?

Solution 1: Hybrid Worker Solution 2: cloud sandbox
Storage network access Private endpoint; public access can be disabled Public endpoint enabled from all networks
Security boundary Network isolation plus authentication and authorization Authentication and authorization, without network isolation
Operations Manage and monitor worker machines, private networking, and DNS No worker machine to manage; monitor the public endpoint and access
Best fit Private-only Storage is required Public endpoint exposure is accepted and sandbox execution is preferred

A Hybrid Worker with a service endpoint and a Storage subnet rule is an intermediate option: the public endpoint remains enabled for selected networks, rather than all networks. It still requires a Hybrid Worker and is not private-endpoint-only access.

Managed identity is the right authentication choice for either solution. It is not a networking feature, so choose the exposure level explicitly and grant the identity only the data access it needs.

Microsoft references