Skip to content

Az.Accounts 5.3.4 — TypeLoadException: Method 'GetTokenAsync' not implemented on Windows PowerShell 5.1 #29384

@mbourgon

Description

@mbourgon

Description

I just spent the last half-day trying to get AzAccounts working after upgrading the Az module - I couldn't log in and got the message described. With Copilot's help in VS Code it finally got it working by downgrading AzAccounts to 5.2.0, which works for me for now, but I've included the details below of what it says the problem is. I had completely uninstalled the AZ module both on the system as admin and as a user, but was getting the problem on reinstall. I do not know how accurate that is, let me be clear, but 5.3.4 doesn't work and 5.2.0 does.

Environment:

PowerShell version: 5.1.26100.7920
OS: Windows 11
Az.Accounts version: 5.3.4 (working: 5.2.0)
Describe the bug:

Both Connect-AzAccount and Disconnect-AzAccount fail in Windows PowerShell 5.1 with:
Method 'GetTokenAsync' in type 'Azure.Identity.InteractiveBrowserCredential'
from assembly 'Azure.Identity, Version=1.13.0.0' does not have an implementation.

This happens regardless of auth method (-UseDeviceAuthentication, interactive, etc). The module loads successfully (Import-Module succeeds) but every cmdlet that invokes authentication fails.

Root cause (suspected):

Az.Accounts 5.3.4 upgraded Azure.Identity from 1.12.x to 1.13.0. In Windows PowerShell 5.1's .NET Framework runtime, the concrete credential classes (InteractiveBrowserCredential, DeviceCodeCredential) fail to satisfy the GetTokenAsync abstract method contract from Azure.Core, resulting in a TypeLoadException at call time. This is a .NET Framework assembly binding/type resolution regression — the same assemblies work fine under .NET 6+/PowerShell 7.

During diagnosis, Azure.Core 1.50.0 and Azure.Identity 1.13.0 were both confirmed loaded from the 5.3.4 module folder, yet the type contract still failed.

Reproduction steps:

Install Az.Accounts 5.3.4 on Windows PowerShell 5.1
Import-Module Az.Accounts
Connect-AzAccount → TypeLoadException
Expected behavior: Successful authentication prompt.

Workaround: Pin to Az.Accounts 5.2.0 (Save-Module Az.Accounts -RequiredVersion 5.2.0) — this ships Azure.Identity 1.12.x and works correctly on PS 5.1.

Possible fix: Either pin Azure.Identity back to < 1.13.0 for the PS 5.1 compatible build, or add a #REQUIRES -Version 7.0 guard and document that 5.3.4+ requires PowerShell 7.

Issue script & Debug output

> disconnect-azaccount
 ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Disconnect-AzAccount], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.Azure.Commands.Profile.DisconnectAzureRmAccountCommand
disconnect-azaccount : Method 'get_SerializationSettings' in type
'Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient' from assembly
'Microsoft.Azure.PowerShell.Clients.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an
implementation.

Environment data

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

Module versions

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     5.2.0      Az.Accounts                         {Disable-AzDataCollection, Disable-AzContextAutosave, Enab...
Script     3.0.0      Az.Advisor                          {Disable-AzAdvisorRecommendation, Enable-AzAdvisorRecommen...
Script     7.1.1      Az.Aks                              {Disable-AzAksAddOn, Enable-AzAksAddOn, Get-AzAksCluster, ...
Script     1.2.0      Az.AnalysisServices                 {Add-AzAnalysisServicesAccount, Export-AzAnalysisServicesI...
Script     4.1.0      Az.ApiManagement                    {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiTo...
Script     2.0.1      Az.App                              {Disable-AzContainerAppRevision, Enable-AzContainerAppRevi...
Script     2.0.1      Az.AppConfiguration                 {Clear-AzAppConfigurationDeletedStore, Get-AzAppConfigurat...
Script     3.0.0      Az.ApplicationInsights              {Get-AzApplicationInsights, Get-AzApplicationInsightsApiKe...
Script     2.0.0      Az.ArcResourceBridge                {Get-AzArcResourceBridge, Get-AzArcResourceBridgeAppliance...
Script     1.0.0      Az.ArizeAI                          {Get-AzArizeAIOrganization, New-AzArizeAIOrganization, Rem...
Script     3.0.0      Az.Attestation                      {Add-AzAttestationPolicySigner, Get-AzAttestationPolicy, G...
Script     2.0.0      Az.Automanage                       {Get-AzAutomanageBestPractice, Get-AzAutomanageConfigProfi...
Script     1.11.2     Az.Automation                       {Export-AzAutomationDscConfiguration, Export-AzAutomationD...
Script     4.0.1      Az.Batch                            {Disable-AzBatchAutoScale, Disable-AzBatchComputeNodeSched...
Script     2.2.0      Az.Billing                          {Get-AzBillingAccount, Get-AzBillingInvoice, Get-AzBilling...
Script     6.0.1      Az.Cdn                              {Add-AzCdnEdgeActionAttachment, Clear-AzCdnEndpointContent...
Script     2.1.2      Az.CloudService                     {Get-AzCloudService, Get-AzCloudServiceInstanceView, Get-A...
Script     1.16.0     Az.CognitiveServices                {Add-AzCognitiveServicesAccountNetworkRule, Get-AzCognitiv...
Script     11.4.0     Az.Compute                          {Add-AzGalleryInVMAccessControlProfileVersionRulesIdentity...
Script     2.0.0      Az.ConfidentialLedger               {Get-AzConfidentialLedger, New-AzConfidentialLedger, New-A...
Script     1.1.1      Az.ConnectedMachine                 {Connect-AzConnectedMachine, Get-AzConnectedExtensionMetad...
Script     4.1.3      Az.ContainerInstance                {Add-AzContainerInstanceOutput, Get-AzContainerGroup, Get-...
Script     5.0.1      Az.ContainerRegistry                {Connect-AzContainerRegistry, Get-AzContainerRegistryManif...
Script     1.20.0     Az.CosmosDB                         {Get-AzCosmosDBAccount, Get-AzCosmosDBAccountKey, Get-AzCo...
Script     1.2.1      Az.DataBoxEdge                      {Get-AzDataBoxEdgeBandwidthSchedule, Get-AzDataBoxEdgeDevi...
Script     1.11.0     Az.Databricks                       {Get-AzDatabricksAccessConnector, Get-AzDatabricksOutbound...
Script     1.19.7     Az.DataFactory                      {Add-AzDataFactoryV2DataFlowDebugSessionPackage, Add-AzDat...
Script     1.1.0      Az.DataLakeAnalytics                {Add-AzDataLakeAnalyticsDataSource, Add-AzDataLakeAnalytic...
Script     1.5.2      Az.DataLakeStore                    {Add-AzDataLakeStoreFirewallRule, Add-AzDataLakeStoreItemC...
Script     1.0.0      Az.DataMigration                    {Get-AzDataMigrationProject, Get-AzDataMigrationService, G...
Script     2.9.1      Az.DataProtection                   {Backup-AzDataProtectionBackupInstanceAdhoc, Edit-AzDataPr...
Script     1.1.1      Az.DataShare                        {Get-AzDataShare, Get-AzDataShareAccount, Get-AzDataShareD...
Script     1.0.0      Az.DataTransfer                     {Approve-AzDataTransferConnection, Deny-AzDataTransferConn...
Script     5.4.1      Az.DesktopVirtualization            {Disconnect-AzWvdUserSession, Expand-AzWvdMsixImage, Get-A...
Script     3.0.0      Az.DevCenter                        {Approve-AzDevCenterUserDevBox, Build-AzDevCenterAdminProj...
Script     1.0.0      Az.DeviceRegistry                   {Get-AzDeviceRegistryAsset, Get-AzDeviceRegistryAssetEndpo...
Script     1.1.0      Az.DevTestLabs                      {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutdownPolic...
Script     2.0.0      Az.Dns                              {Add-AzDnsRecordConfig, Get-AzDnsRecordSet, Get-AzDnsZone,...
Script     1.2.3      Az.DnsResolver                      {Get-AzDnsForwardingRuleset, Get-AzDnsForwardingRulesetFor...
Script     1.7.0      Az.ElasticSan                       {Add-AzElasticSanVolumeGroupNetworkRule, Get-AzElasticSan,...
Script     2.2.0      Az.EventGrid                        {Disable-AzEventGridPartnerTopic, Enable-AzEventGridPartne...
Script     5.4.0      Az.EventHub                         {New-AzEventHubAuthorizationRuleSASToken, Approve-AzEventH...
Script     1.0.0      Az.Fabric                           {Get-AzFabricCapacity, Get-AzFabricCapacitySku, New-AzFabr...
Script     1.0.0      Az.FirmwareAnalysis                 {Get-AzFirmwareAnalysisBinaryHardening, Get-AzFirmwareAnal...
Script     2.1.0      Az.FrontDoor                        {Disable-AzFrontDoorCustomDomainHttps, Enable-AzFrontDoorC...
Script     4.3.2      Az.Functions                        {Get-AzFunctionApp, Get-AzFunctionAppAvailableLocation, Ge...
Script     6.4.0      Az.HDInsight                        {Add-AzHDInsightClusterIdentity, Add-AzHDInsightComponentV...
Script     3.0.0      Az.HealthcareApis                   {Get-AzHealthcareApisService, Get-AzHealthcareApisWorkspac...
Script     1.0.0      Az.HealthDataAIServices             {Get-AzDeidService, New-AzDeidService, Remove-AzDeidServic...
Script     2.8.1      Az.IotHub                           {Add-AzIotHubCertificate, Add-AzIotHubConfiguration, Add-A...
Script     6.4.3      Az.KeyVault                         {Add-AzKeyVaultCertificate, Add-AzKeyVaultCertificateConta...
Script     2.4.0      Az.Kusto                            {Add-AzKustoClusterCalloutPolicy, Add-AzKustoClusterLangua...
Script     1.0.0      Az.LambdaTest                       {Get-AzLambdaTestOrganization, New-AzLambdaTestOrganizatio...
Script     1.1.1      Az.LoadTesting                      {Get-AzLoad, New-AzLoad, Remove-AzLoad, Update-AzLoad}
Script     1.6.0      Az.LogicApp                         {Get-AzIntegrationAccount, Get-AzIntegrationAccountAgreeme...
Script     1.2.0      Az.MachineLearning                  {Add-AzMlWebServiceRegionalProperty, Export-AzMlWebService...
Script     1.3.0      Az.MachineLearningServices          {Get-AzMLServiceQuota, Get-AzMLServiceUsage, Get-AzMLServi...
Script     1.5.1      Az.Maintenance                      {Get-AzApplyUpdate, Get-AzConfigurationAssignment, Get-AzM...
Script     2.0.0      Az.ManagedServiceIdentity           {Get-AzFederatedIdentityCredential, Get-AzSystemAssignedId...
Script     3.1.3      Az.ManagedServices                  {Get-AzManagedServicesAssignment, Get-AzManagedServicesDef...
Script     2.2.0      Az.MarketplaceOrdering              {Get-AzMarketplaceTerms, Invoke-AzMarketplaceSignTerms, Se...
Script     2.12.0     Az.Migrate                          {Get-AzMigrateDiscoveredServer, Get-AzMigrateJob, Get-AzMi...
Script     7.0.0      Az.Monitor                          {Add-AzLogProfile, Add-AzMetricAlertRule, Add-AzMetricAler...
Script     1.5.2      Az.MySql                            {Get-AzMySqlConfiguration, Get-AzMySqlConnectionString, Ge...
Script     1.1.0      Az.NetAppFiles                      {Approve-AzNetAppFilesReplication, Get-AzNetAppFilesAccoun...
Script     7.26.0     Az.Network                          {Add-AzApplicationGatewayAuthenticationCertificate, Add-Az...
Script     2.0.0      Az.NetworkCloud                     {Deploy-AzNetworkCloudCluster, Disable-AzNetworkCloudStora...
Script     2.0.0      Az.Nginx                            {Get-AzNginxCertificate, Get-AzNginxConfiguration, Get-AzN...
Script     1.2.0      Az.NotificationHubs                 {Get-AzNotificationHub, Get-AzNotificationHubAuthorization...
Script     3.3.0      Az.OperationalInsights              {Disable-AzOperationalInsightsIISLogCollection, Disable-Az...
Script     2.0.0      Az.Oracle                           {Add-AzOracleCloudVMClusterVM, Get-AzOracleAutonomousDatab...
Script     1.7.3      Az.PolicyInsights                   {Get-AzPolicyAttestation, Get-AzPolicyEvent, Get-AzPolicyM...
Script     1.4.0      Az.PostgreSql                       {Get-AzPostgreSqlConfiguration, Get-AzPostgreSqlConnection...
Script     2.1.0      Az.PowerBIEmbedded                  {Get-AzPowerBIEmbeddedCapacity, New-AzPowerBIEmbeddedCapac...
Script     1.2.0      Az.PrivateDns                       {Add-AzPrivateDnsRecordConfig, Get-AzPrivateDnsRecordSet, ...
Script     7.11.2     Az.RecoveryServices                 {Add-AzRecoveryServicesAsrReplicationProtectedItemDisk, Ba...
Script     1.11.0     Az.RedisCache                       {Export-AzRedisCache, Get-AzRedisCache, Get-AzRedisCacheFi...
Script     1.6.1      Az.RedisEnterpriseCache             {Export-AzRedisEnterpriseCache, Get-AzRedisEnterpriseCache...
Script     3.0.0      Az.Relay                            {Get-AzRelayAuthorizationRule, Get-AzRelayHybridConnection...
Script     1.2.1      Az.ResourceGraph                    {Search-AzGraph, Get-AzResourceGraphQuery, New-AzResourceG...
Script     1.3.1      Az.ResourceMover                    {Add-AzResourceMoverMoveResource, Get-AzResourceMoverMoveC...
Script     9.0.3      Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDeny...
Script     1.8.0      Az.Security                         {Add-AzSecurityAdaptiveNetworkHardening, Add-AzSecuritySql...
Script     3.2.1      Az.SecurityInsights                 {Get-AzSentinelAlertRule, Get-AzSentinelAlertRuleAction, G...
Script     4.1.1      Az.ServiceBus                       {New-AzServiceBusAuthorizationRuleSASToken, Test-AzService...
Script     5.1.0      Az.ServiceFabric                    {Add-AzServiceFabricClientCertificate, Add-AzServiceFabric...
Script     2.3.3      Az.SignalR                          {Add-AzSignalRNetworkIpRule, Get-AzSignalR, Get-AzSignalRC...
Script     6.4.1      Az.Sql                              {Add-AzSqlDatabaseToFailoverGroup, Add-AzSqlElasticJobStep...
Script     2.4.1      Az.SqlVirtualMachine                {Assert-AzSqlVMEntraAuth, Get-AzAvailabilityGroupListener,...
Script     2.6.6      Az.StackHCI                         {Add-AzStackHCIVMAttestation, Disable-AzStackHCIAttestatio...
Script     1.1.1      Az.StackHCIVM                       {Add-AzStackHCIVMVirtualMachineDataDisk, Add-AzStackHCIVMV...
Script     9.6.0      Az.Storage                          {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountMa...
Script     1.0.1      Az.StorageAction                    {Get-AzStorageActionTask, Get-AzStorageActionTaskAssignmen...
Script     1.0.0      Az.StorageDiscovery                 {Get-AzStorageDiscoveryWorkspace, New-AzStorageDiscoverySc...
Script     2.0.0      Az.StorageMover                     {Get-AzStorageMover, Get-AzStorageMoverAgent, Get-AzStorag...
Script     2.5.2      Az.StorageSync                      {Get-AzStorageSyncCloudEndpoint, Get-AzStorageSyncGroup, G...
Script     3.0.0      Az.StreamAnalytics                  {Get-AzStreamAnalyticsCluster, Get-AzStreamAnalyticsCluste...
Script     2.1.0      Az.Support                          {Get-AzSupportChatTranscript, Get-AzSupportChatTranscripts...
Script     3.2.4      Az.Synapse                          {Add-AzSynapseDataFlowDebugSessionPackage, Add-AzSynapseTr...
Script     1.3.0      Az.TrafficManager                   {Add-AzTrafficManagerCustomHeaderToEndpoint, Add-AzTraffic...
Script     3.4.2      Az.Websites                         {Add-AzWebAppAccessRestrictionRule, Add-AzWebAppTrafficRou...
Script     2.0.0      Az.Workloads                        {Get-AzWorkloadsMonitor, Get-AzWorkloadsProviderInstance, ...

Error output

(unsure if this is the right error; I only ran all of this after I got things working, since I originally thought it was user error)

Message        : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more
                 information.
StackTrace     :    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
                    at System.Reflection.RuntimeModule.GetTypes()
                    at System.Reflection.Assembly.GetTypes()
                    at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblyFromPathOrName(List`1 generatedTypes)
                    at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()
                    at System.Management.Automation.CommandProcessorBase.Complete()
Exception      : System.Reflection.ReflectionTypeLoadException
InvocationInfo : {Add-Type}
Line           :             Add-Type -Path $path -ErrorAction Ignore | Out-Null

Position       : At C:\Users\xxx\AppData\Local\WindowsPowerShell\Modules\Az.Accounts\5.3.4\Az.Accounts.psm1:74
                 char:13
                 +             Add-Type -Path $path -ErrorAction Ignore | Out-Null
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 9

Message        : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more
                 information.
StackTrace     :    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
                    at System.Reflection.RuntimeModule.GetTypes()
                    at System.Reflection.Assembly.GetTypes()
                    at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblyFromPathOrName(List`1 generatedTypes)
                    at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()
                    at System.Management.Automation.CommandProcessorBase.Complete()
Exception      : System.Reflection.ReflectionTypeLoadException
InvocationInfo : {Add-Type}
Line           :             Add-Type -Path $path -ErrorAction Ignore | Out-Null

Position       : At C:\Users\xxxx\AppData\Local\WindowsPowerShell\Modules\Az.Accounts\5.3.4\Az.Accounts.psm1:74
                 char:13
                 +             Add-Type -Path $path -ErrorAction Ignore | Out-Null
                 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 9

Metadata

Metadata

Assignees

Labels

act-identity-squadbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reported

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions