Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your Azure credentials

Hi all,

Sometimes, you may encounter the following error when trying to run an Azure PowerShell command.

‘Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your Azure credentials’

Snap 2015-04-02 at 11.44.31

Obviously, even with running the Add-AzureAccount  for several times, the error stills there:  Restarting PowerShell, restarting Windows, login/logout form the portal does not solve the issue.

I have been in this problem many times, but today, it was the worst, 30 minutes of googling and binging and the error won’t go away. The proposed solution was to run the Remove-AzureAccount PowerShell command to remove the stored Azure account from the computer. But again, I still get the error message. However, a small detail intrigues me : The    Remove-AzureAccount command is requesting the Azure account  to be removed and I remembered that i ‘m using two Azure accounts on my computer (My user session).

Snap 2015-04-02 at 11.43.12

So I run the Get-AzureAccount command to show the stored Azure Accounts on my session

Snap 2015-04-02 at 11.43.37

I guess this is the culprit, I have more than one Azure account so maybe this is why I still get the error. I decided to remove all the Azure accounts using one stone

foreach ($AzureAccount in (Get-AzureAccount).ID) {Remove-AzureAccount $AzureAccount}

Snap 2015-04-02 at 11.56.58

And bingo, adding an Azure account and then running commands worked like a charm. No more errors.

Advertisements

One thought on “Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your Azure credentials

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