Powershell Connect-AzAccount error

Frederick 1 Reputation point

I have a PS script that runs > 'Connect-AzAccount' in an Azure Cloud VM.... when it gets to that point I get an error of...

'WARNING: unable to acquire token for tenant '.......'


Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
662 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,370 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,471 Reputation points

    Do you have AzureRm installed?
    You should uninstall it as it is not compatible with Az module.

    Hope this helps.

    2 people found this answer helpful.
    0 comments No comments

  2. Cristian SPIRIDON 4,471 Reputation points

    Can you run Clear-AzContext and try again?

    I might solve your issue.

    1 person found this answer helpful.

  3. Andreas Baumgarten 99,461 Reputation points MVP

    Maybe this helps:

     $azureContext = Get-AzContext
     until (!$azureContext)

    This will disconnect all existing Azure connections.

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Andreas Baumgarten

    1 person found this answer helpful.

  4. Winston 2,766 Reputation points

    Hey @Frederick ,

    If your still unable to connect to your Az Account after clearing your local PowerShell Context and your using only the Az PowerShell module, (see earlier answer stating that the older AzureRM PowerShell modules are outdated) you should try to remove the module and re-add it. It appears to be an issue with the module. Can you also provide more information about the underlying machine, what version of PowerShell your using, and the version of the module? Thanks!

    0 comments No comments