question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connect-AzAccount does not work in PowerShell Integrated Console

See original GitHub issue

Note, the solution is posted in the Azure PowerShell module. They have a temporary engineering built of the Az.Accounts module, with version 2.6.2 with instructions on how to install. The link is here: https://github.com/Azure/azure-powershell/issues/16340


Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

I have setup VS Code on 2 new computers and they are both having the same issue. I have the Integrated PowerShell Console set to load Windows PowerShell 5.1. When I run a script, the PowerShell Integrated Console (PIC) gives the error shown below. Even if I type the Connect-AzAccount manually in the PIC I get the same error. However, if I switch the terminal to Windows PowerShell (not Integrated), the command works fine (it loads the login prompt in an external PowerShell window). But when I run any script it automatically switches back to the PIC. Note that PowerShell Core works fine, it loads the login prompt in a browser window.

I have one older computer running Windows 10 that has had VS Code configured for years that is not showing the problem. I tried copying all the settings in the %appdata%, but it did not solve the problem.

Error: WARNING: Unable to acquire token for tenant ‘organizations’ with error ‘Method ‘GetTokenAsync’ in type ‘Azure.Identity.InteractiveBrowserCredential’ from assembly ‘Azure.Identity, Version=1.4.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8’ does not have an implementation.’
Connect-AzAccount : Method ‘GetTokenAsync’ in type ‘Azure.Identity.InteractiveBrowserCredential’ from assembly ‘Azure.Identity, Version=1.4.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8’ does not have an implementation. At line:1 char:1

  • Connect-AzAccount
  •   + CategoryInfo          : CloseError: (:) [Connect-AzAccount], TypeLoadException
      + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
    
    

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.22000.282
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.282
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Visual Studio Code Version

1.61.2
6cba118ac49a1b88332f312a8f67186f7f3c1643
x64

Extension Version

ms-vscode.powershell@2021.10.1

Steps to Reproduce

Install VS Code Install PowerShell Az modules (Install-Module -Name Az) Set the default console to be Windows PowerShell 5.1 so that the PowerShell Integrated Console runs with Windows PowerShell. Type the command in the PowerShell Integrated Console window or put the command in a script and run: Connect-AzAccount

Visuals

image

image

Logs

logs.zip

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:31 (13 by maintainers)

github_iconTop GitHub Comments

5reactions
bizon80commented, Nov 5, 2021

Hi, Had the same issue, and not sure but there is a workaround that worked for me at least. When you get the error message in VS Code: WARNING: Unable to acquire token for tenant ‘organizations’ with error ‘Method ‘GetTokenAsync’ in type ‘Azure.Identity.InteractiveBrowserCredential’ from assembly ‘Azure.Identity, Version=1.4.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8’ does not have an implementation.’ Connect-AzAccount : Method ‘GetTokenAsync’ in type ‘Azure.Identity.InteractiveBrowserCredential’ from assembly ‘Azure.Identity, Version=1.4.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8’ does no t have an implementation.

Just click ‘New Terminal Window’ and rerun. It worked for me. image

3reactions
markr-rpccommented, Nov 5, 2021

I have updated the Azure PowerShell modules to 6.6.0 and am getting the same results. I have created an issue with the Azure PowerShell team, as noted above. The Az.Accounts is now at version 2.6.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Within Visual Studio Code PowerShell keeps hanging when ...
i try to use "Connect-AzAccount" to login to Azure. It looks like in the background PowerShell is busy (maybe with MFA) but no...
Read more >
Connect-AzAccount (Az.Accounts) | Microsoft Learn
The Connect-AzAccount cmdlet connects to Azure with an authenticated account for use with cmdlets from the Az PowerShell modules. You can use this ......
Read more >
The term 'Connect-AzAccount' is not recognized as the name ...
Connect -AzAccount : The term 'Connect-AzAccount' is not recognized as the name of a cmdlet · Step 1 : Open Powershell in your...
Read more >
Different ways to login to Azure automation using PowerShell
In this case, login-AzAccount cmdlet accepts the credentials to run the session with the context of the specified user. In order to do...
Read more >
The specified module 'Module Name' was not loaded because ...
Problem : When trying to import the PnP PowerShell module, I got an error message ... To get the modules installed, Open PowerShell...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found