skip to Main Content

In Azure automation runbook I want to connect with storage account and get the context without the account key. I can connect with the storage account key but I don’t want to connect with storage key.

FYI

$Context = New-AzStorageContext -StorageAccountName "cordus6abfsuat001" -UseConnectedAccount
echo $Context

ERROR is "Context cannot be null."

I am expecting to connect with storage account with out the storage account key.

2

Answers


  1. You can use a system-assigned managed identity for you Azure Automation account
    enter image description here

    Then, in your storage account, you got to:

    1. Access Control
    2. Add Role Assignment
      enter image description here

    There you can give the Role Contributor for your Automation Account Identity
    enter image description here
    enter image description here
    enter image description here
    Hoppe This helps!

    Login or Signup to reply.
  2. I am expecting to connect with storage account with out the storage account key.

    You can alternatively use Connection string and get the context as below and I followed Microsoft-Document:

    Connect-AzAccount
    
    $Context = New-AzStorageContext -ConnectionString "XX"
    
    Write-Host $Context
    

    XX is the Connection string of Storage account.

    enter image description here

    Output:

    enter image description here

    You can also get it with uisng SAS token as below:

    $Context = New-AzStorageContext -StorageAccountName "rithvayamo" -SasToken "sp=r&st=2022i4n3vHCuHye6PzkDLUbXTnQT2jeNphU1j0%3D"
    
    Write-Host $Context
    

    enter image description here

    Output:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search