vscode-powershell: Connect-AzAccount does not work in PowerShell Integrated Console

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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 31 (12 by maintainers)

Most upvoted comments

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

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

Same problem here

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