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


Azure is a pretty sweet cloud environment, with a powerful management portal to help you drive ops.  But the management portal isn’t enough when it comes to quickly scaling up operations. PowerShell is available from a DevOps perspective to script a large variety of tasks. Sometimes though, you get some strange errors out of PowerShell cmdlets.

I was running the Get-AzureVM cmdlet and got the error – “Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your Azure credentials”. Which was frustrating to me, as I was sure the Azure account I had selected using Select-AzureSubscription in my account was valid.  I had setup several websites and a storage account in it earlier in the year.

Running Add-AzureAccount did nothing to resolve the error.  Creds were stored and visible via Get-AzureSubscription cmdlet.  I was at a wall. Then I took a step back.

Resolution – Login to the Azure portal and check your account status. Mine was still in the “welcome wizard” even though I already had a few websites running in it. Walking through the wizard cleared up the message and now the scripts run successfully.

Here’s to the SEO god, may this post help some other person not spend an hour wrestling out of an awkward situation.

Additional keywords: Select-AzureSubscription Get-AzureVM FullyQualifiedErrorId Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand

Comments (16)

  1. Azure Master says:

    sorry, I was wrong, your topic is good

  2. Alex's Cloud says:

    Alright Joe, I'm getting the same issue, but my account status is Active.  What next?

  3. jhealy says:

    @alex – pop me an email to jhealy at Microsoft dot com …  Lets see where it can go.

  4. veaziemi19 says:

    I had the same error and it was caused by the newest versions of Azure PowerShell. I had to install back to version 8.14 (February 2015) in order for it to work.

    az412849.vo.msecnd.net/…/azure-powershell.0.8.14.msi

  5. jhealy says:

    @veaziemi19 – great tip.  thanks for sharing..

  6. HdZ says:

    @veaziemi19 – thanks, this was the solution to my problem as well 🙂

  7. Dmytro Mykhailov says:

    Got same problem. However my account status – active.

    Installing powershell tools from Feb 2015 got message that I already have newer tools and it won't do anything.

    Any other ideas what can I do to make by account working?

  8. Dmytro Mykhailov says:

    I found an article about that issue: http://www.heukels.nz/…/your-azure-credentials-have-not-been.html

    So, I removed azure account and when I try to add it back it says:

    Add-AzureAccount : The given key was not present in the dictionary.

  9. Dmytro Mykhailov says:

    Managed to fix the issue. Basically for me it was:

    1. Remove-AzureAccount (for all accounts)

    2. Clear-AzureProfile

    3. Add-AzureAccount

  10. jhealy says:

    @dmytro – thanks for shareing.  this is an awkward process to figure out whats going wrong, and all tips are welcome!

  11. Todd says:

    adding Clear-AzureProfile before the Add-AzureAccount cleared up my script where I was having this issue; I never had to do this before but I am juggling several Azure accounts

  12. TZiegner says:

    As mentioned, this issue is the result of having more than one Azure account setup with a instance of Azure PowerShell on a PC. Run 'Get-AzureAccount' to see what subscriptions are associated with the Azure PowerShell instance on your PC.  Then, run 'foreach ($AzureAccount in (Get-AzureAccount).ID) {Remove-AzureAccount $AzureAccount}' to remove all of those accounts.  Finally, use the 'Add-AzureAccount' command to add the one and only one Azure Subscription that you wish to access with your instance of Azure PowerShell (running your machine.)  This method resolved the issue for us.

  13. patrick says:

    Thanks, this worked:

    1. Remove-AzureAccount (for all accounts)

    2. Clear-AzureProfile

    3. Add-AzureAccount

  14. Jim W. _ says:

    Thanks for posting and to everyone for the comments.  Clear-AzureProfile did the trick for me.

  15. Kazu Mai says:

    I am stuck with this for a long time, if someone can help. please help me

    my powershell is

    Name             : Windows PowerShell ISE Host

    Version          : 3.0

    so first step is

    PS C:Windowssystem32> Add-AzureAccount

    Add-AzureAccount : The given key was not present in the dictionary.

    At line:1 char:1

    + Add-AzureAccount

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

       + CategoryInfo          : CloseError: (:) [Add-AzureAccount], KeyNotFoundException

       + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount

    so I followed

    1. Remove-AzureAccount (for all accounts)

    2. Clear-AzureProfile

    3. Add-AzureAccount

    PS C:Windowssystem32> Remove-AzureAccount

    cmdlet Remove-AzureAccount at command pipeline position 1

    Supply values for the following parameters:

    (Type !? for Help.)

    Name: kazu.mai@susco.net

    Remove-AzureAccount : User name is not valid.

    Parameter name: accountId

    At line:1 char:1

    + Remove-AzureAccount

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

       + CategoryInfo          : CloseError: (:) [Remove-AzureAccount], ArgumentException

       + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.RemoveAzureAccountCommand

    what this error mean? How can I log in back to powershell.

  16. MCulp says:

    thanks veaziemi19 – none of the other options worked for me.  I loaded 8.14 version (removed Nov. version) and is working.  must be an ongoing bug in versions past 8.14 – who can ask for the fix?

Skip to main content