I am trying to run a powershell script from azure automation account, to list blobs in storage account. This storage account has network rules for selected networks only, tried to provide access keys and SAS into scripts, but still i see 403 error. How can i run my script and list blobs with network restriction?
$StorageAccountName = 'xyz'
$key = get-azstorageaccountkey -storageaccountname $StorageAccountName -resourcegroupname "xxxxxx"
$StorageAccountKeyPrimary = $key[0].value
$ContainerName = 'xxx'
$StorageContext = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKeyPrimary
$Blobs = Get-AzStorageBlob -Container $ContainerName -Context $StorageContext | Where-Object{$_.LastModified.Date -lt (Get-Date).AddDays(-30)}
$Blobs | ft -property name, LastModified
$totalblobs = $Blobs.Count
Write-Output "Total blobs in container = $totalblobs"