403 error access blob from azure automation runbook

Arif Usman 496 Reputation points
2025-12-10T02:29:13.68+00:00

folks, I am trying to access blob in storage account from azure automation account runbook and getting following error in runbook.

===============================================

Environments                                                                                           Context
------------                                                                                           -------
{[AzureUSGovernment, AzureUSGovernment], [AzureChinaCloud, AzureChinaCloud], [AzureCloud, AzureCloud]} Microsoft.Azure.…
Get-AzStorageBlob: 
Line |
   3 |  $blob = Get-AzStorageBlob -Container "sqlbackup" -Context $ctx
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | This request is not authorized to perform this operation.
RequestId:8f59929b-d01e-005f-0a74-694c02000000
Time:2025-12-10T01:30:16.3669972Z
Status: 403 (This request is not authorized to perform this operation.)
ErrorCode: AuthorizationFailure
Content:
<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthorizationFailure</Code><Message>This request is not authorized to perform this operation.
RequestId:8f59929b-d01e-005f-0a74-694c02000000
Time:2025-12-10T01:30:16.3669972Z</Message></Error>
Headers:
Server: Microsoft-HTTPAPI/2.0
x-ms-request-id: 8f59929b-d01e-005f-0a74-694c02000000
x-ms-client-request-id: 949743df6eb2-8810656c-3172-4b70-bccc-949743df6eb2
x-ms-error-code: AuthorizationFailure
Date: Wed, 10 Dec 2025 01:30:15 GMT
Content-Length: 246
Content-Type: application/xml
Blob: ctx Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext 

==========================================================================================================

this is in the runbook to test

Connect-AzAccount -Identity
$ctx = New-AzStorageContext -StorageAccountName "storageaccountname" -UseConnectedAccount
$blob = Get-AzStorageBlob -Container "sqlbackup" -Context $ctx
Write-Output "Blob:$blob ctx $ctx"

Automation account has system identity enable.

Automation account of manage identity has 'Network Contributor', 'Reader', 'Storage Blob Data Contributor' role access in storage account.

Storage account and Automation have private endpoint (public access is disable). Both resources use same vnet and subnet in same resource group of subscription. Not sure why am I getting 403 error. Manage identity of aa has been given to storage account.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-10T02:29:27.0833333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The 403 error you are encountering when trying to access the Azure Blob Storage from your Azure Automation runbook indicates an authorization failure. Here are some potential causes and solutions to consider:

    1. Network Restrictions: Since both the storage account and the automation account have a private endpoint and public access is disabled, ensure that the Azure Automation runbook is configured to access resources through the virtual network. If the Azure Firewall is enabled on the storage account, it may block access from Azure Automation runbooks. You might need to use a Hybrid Runbook Worker to facilitate this access.
    2. Role Assignments: Although you mentioned that the managed identity of the automation account has the "Storage Blob Data Contributor" role, ensure that this role is assigned at the correct scope (e.g., storage account level). Also, verify that there are no additional role restrictions that might be affecting access.
    3. Run As Account Permissions: If you are using a Run As account, ensure that it has the necessary permissions to access the storage account. The Run As account might not have the same permissions as the managed identity.
    4. Check for IP Restrictions: Ensure that there are no IP address restrictions that could be blocking access to the storage account from the automation account.
    5. Service Endpoint Configuration: Confirm that the service endpoint for Azure Storage is correctly configured in your virtual network settings.

    By reviewing these areas, you should be able to identify the root cause of the 403 error and resolve the issue.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.