Tuesday, February 20, 2024

Az.Accounts module causes error in VSCode

 

When attempting to make an Azure connection the following error occurs:

Connect-AzAccount : Method 'get_SerializationSettings' in type 'Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient' from assembly 'Microsoft.Azure.PowerShell.Clients.Reso

urceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.

At line:1 char:1

+ Connect-AzAccount

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

    + CategoryInfo          : NotSpecified: (:) [Connect-AzAccount], TypeLoadException

    + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand


This is discussed in https://github.com/Azure/azure-powershell/issues/21960

The solution is to close VSCode and install a previous version 2.12.2 using

Install-Module -Name Az.Accounts -RequiredVersion 2.12.2

Then remove the faulty version 2.15.1 in this case

Uninstall-Module -Name "Az.Accounts" -RequiredVersion 2.15.1

Connect-AzAccount then correctly prompts for credentials


While you are now able to us Connect-AzAccount in VSCode in may not be much use because it may be in compatible with other modules such as Az.DesktopVirtualistation.

You may be forced to run up to date compatible modules entirely from ISE.