Powershell Connect-AzAccount error

Frederick 1 Reputation point
2020-12-04T20:32:50.843+00:00

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 '.......'

45259-screen-shot-2020-12-03-at-112959-am.png

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

4 answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,471 Reputation points
    2020-12-05T08:51:12.287+00:00

    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
    2020-12-04T21:25:44.26+00:00

    Can you run Clear-AzContext and try again?

    I might solve your issue.

    1 person found this answer helpful.

  3. Andreas Baumgarten 96,926 Reputation points MVP
    2020-12-04T23:14:03.637+00:00

    Maybe this helps:

    do{
     Disconnect-AzAccount
     $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)

    Regards
    Andreas Baumgarten

    1 person found this answer helpful.

  4. Winston 2,761 Reputation points
    2020-12-06T02:27:09.347+00:00

    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