Error when executing : Get-Azurestoragecontainer Can not find your azure storage credential. Please set current storage account using “Set-AzureSubscription” or set current storage account using “Set-AzureSubscription” or set the “AZURE_STORAGE_CONNECTION_STRING” environment variable.

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

+ Get-AzureStorageContainer

+ ~~~~~~~~~~~~~~~~~~~~~~~~~

+ 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

 
 


Resolution

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

Step 1:

Extracting Management Certificates Thumbprint


 
 

Step 2:

Get-Item to extract the Certification information from local certificate store

 
 


 
 

Step 3:

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.


 
 

Step 4:

After setting the value of the Storage Account, when you run the Get-Azurestoragecontainer, it will display the following values.


 
 

Thanks for reading

Krishna

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s