Share via

Error about permission with Powershell command Get-AzureStorageBlob in Azure Runbook

Ellen Heijmans 21 Reputation points
2022-01-27T14:02:45.69+00:00

I'm trying to create a runbook in Azure that accesses a blob storage and list the contents. But I keep getting the following error:

The remote server returned an error: (403) Forbidden. HTTP Status Code: 403 - HTTP Error Message: This request is not authorized to perform this operation using this permission.

I checked the following:
Azure Portal -> Storage Account -> Networking -> Check Allow Access From (All Networks / Selected Networks)
It is set to all networks.

I checked the SAS. It's correct.

On the storage account and the container I set the Access Control to Storage Blob Data Reader and Sotrage Blob Data Owner to Managed Identity\Automation Account

i created an Access Policy and set its rights to rdl, but I don't know how to call it from within my Powershell statement. I don't know whether it makes any difference.

Who can help me? I've about read all the articles on Internet but can't find the answer.

It's the statement Get-AzureStorageBlob that fails.

This is the code in the runbook:

$storage = "opslag" #name of storage account
$blobcontainer = "contener" #name of container
$sas = "****"

Write-Output $storage
Write-Output $container

$context = New-AzureStorageContext -StorageAccountName $storage -SasToken $sas
Write-Output $context

$blobs = Get-AzureStorageBlob -Container $blobcontainer -Context $context

Write-Output "Klaar!"

Azure Storage
Azure Storage

Globally unique resources that provide access to data management services and serve as the parent namespace for the services.

Azure Automation
Azure Automation

An Azure service that is used to automate, configure, and install updates across hybrid environments.


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.