When you try to get list of Containers for a given storage account, you might encounter the following error, if default storage account is not set.
Get-AzureStorageContainer : Can not find your azure storage credential. Please set current storage account using “Set-AzureSubscription” or set the “AZURE_STORAGE_CONNECTION_STRING” environment variable.
At line:1 char:1
+ CategoryInfo : InvalidArgument: (:) [Get-AzureStorageContainer], ArgumentException
+ FullyQualifiedErrorId : ArgumentException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageContainerCommand
The issue is because the CurrentStorageAccountName is not set. The way to verify if that’s the case, type in the following as shown below
The Set-Azuresubscription will fix the issue. In the next steps, we will see how to go about it to get issue resolved.
Set-AzureSubscription -SubscriptionName “subscriptionName” –SubscriptionId “subscriptionName” –Certificate “Certficiate” -CurrentStorageAccountName “NameoftheStorageAccount”
Do note, there is no need to set certificate value, but i do set it up as general practice. Just setting up the CurrentStorageaccount will fix the issue.
Also ,the subscriptionName and subscriptionID can be extracted from Get-Azuresubscription, the certificates might be tricky to resolve if you are newbie to Azure PowerShell. Following steps below on how to get the Certificate information.
To get the value of the Certificate do the following – Navigate to Settings-> Management Certificates -> Thumbprint
Extracting Management Certificates Thumbprint
Get-Item to extract the Certification information from local certificate store
Execute the Set-Azuresubscription to set the currentstorage
Set-AzureSubscription -SubscriptionName “Subname” -SubscriptionId “Subid” -Certificate $managementCertificate -CurrentStorageAccountName “testverbosevmstorage”
When you run Get-Azuresubscription, following value is displayed. See the CurrentStorageAccountName.
After setting the value of the Storage Account, when you run the Get-Azurestoragecontainer, it will display the following values.
Thanks for reading