Home > OS >  How to connect with Storage account in Azure automation runbook
How to connect with Storage account in Azure automation runbook

Time:12-21

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.

CodePudding user response:

You can use a 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!

CodePudding user response:

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="

Write-Host $Context

enter image description here

Output:

enter image description here

  • Related