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:
Then, in your storage account, you got to:
There you can give the Role Contributor for your Automation Account Identity 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.
Output:
You can also get it with uisng SAS token as below:
$Context = New-AzStorageContext -StorageAccountName "rithvayamo" -SasToken "sp=r&st=2022i4n3vHCuHye6PzkDLUbXTnQT2jeNphU1j0="
Write-Host $Context
Output: