Share via


Get Azure Storage Connection String with PowerShell

Question

Wednesday, February 20, 2019 2:47 PM

Hello

We need to read the connection string of an Azure storage account. Is there an equivalent option to Azure CLI

az storage account show-connection-string

in Azure PowerShell? Couldn't find anything in the docs.

Thanks,
Manuel

All replies (2)

Wednesday, February 20, 2019 4:38 PM âś…Answered

Hi Manuel, 

try the following:

$sa = Get-AzStorageAccount -StorageAccountName $saName -ResourceGroupName $rgName

$saKey = (Get-AzStorageAccountKey -ResourceGroupName $rgName -Name $saName)[0].Value

'DefaultEndpointsProtocol=https;AccountName=' + $saName + ';AccountKey=' + $saKey + ';EndpointSuffix=core.windows.net' 

hth
Marcin


Thursday, February 21, 2019 7:29 AM

Hello Marcin

*facepalm*

Of course! As usual looked for the more complicated solution instead of the easy one :)

Thank you very much!