Skip to content

When recent Az.* modules are loaded, Connect-MgGraph errors out #2587

Closed
@joshtransient

Description

@joshtransient

Describe the bug
In a session where Az modules such as Az.Accounts and Az.KeyVault are loaded, Connect-MgGraph does not connect at all.

  • When trying to connect interactively, the error is "Method not found: 'System.Threading.Tasks.Task`1<Azure.Identity.AuthenticationRecord>
    Azure.Identity.InteractiveBrowserCredential.AuthenticateAsync(Azure.Core.TokenRequestContext, System.Threading.CancellationToken)'."
  • When trying to connect with an app registration and a secret or cert, the error is "Entry point was not found."

I believe the Az modules are using a newer version of MSAL that isn't compatible with the current ones included with the Graph PowerShell SDK modules. PnP v2+ couldn't happily coexist with Az modules either, until the latest release of the Az modules.

To Reproduce

  1. Open a new PowerShell prompt and import the Az.Accounts module
  2. Import Microsoft.Graph.Authentication and run Connect-MgGraph with any authentication option

Expected behavior
Running Connect-MgGraph should establish a connection to Graph instead of erroring out

Debug Output
When connecting with a certificate:

DEBUG: ClientCertificateCredential.GetToken invoked. Scopes: [ https://graph.microsoft.com/.default ] ParentRequestId:
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Microsoft Windows 10.0.22621 [2024-02-13 17:01:06Z - d75e3fa0-444b-4e7c-bac1-a89548c43106] MSAL MSAL.CoreCLR with assembly version '4.56.0.0'. CorrelationId(d75e3fa0-444b-4e7c-bac1-a89548c43106)
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Microsoft Windows 10.0.22621 [2024-02-13 17:01:06Z - d75e3fa0-444b-4e7c-bac1-a89548c43106] === AcquireTokenForClientParameters ===
SendX5C: False
ForceRefresh: False

DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Microsoft Windows 10.0.22621 [2024-02-13 17:01:06Z - d75e3fa0-444b-4e7c-bac1-a89548c43106]
=== Request Data ===
Authority Provided? - True
Scopes - https://graph.microsoft.com/.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenForClient
IsConfidentialClient - True
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - d75e3fa0-444b-4e7c-bac1-a89548c43106
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:

DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Microsoft Windows 10.0.22621 [2024-02-13 17:01:06Z - d75e3fa0-444b-4e7c-bac1-a89548c43106] === Token Acquisition (ClientCredentialRequest) started:
         Scopes: https://graph.microsoft.com/.default
        Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Microsoft Windows 10.0.22621 [2024-02-13 17:01:06Z - d75e3fa0-444b-4e7c-bac1-a89548c43106] [Instance Discovery] Instance discovery is enabled and will be performed
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Microsoft Windows 10.0.22621 [2024-02-13 17:01:06Z - d75e3fa0-444b-4e7c-bac1-a89548c43106] [Region discovery] Not using a regional authority.
DEBUG: Request [71625b4f-01cf-4303-ba75-14d2395837bd] POST https://login.microsoftonline.com/raggedsail.onmicrosoft.com/oauth2/v2.0/token
x-client-SKU:REDACTED
x-client-Ver:REDACTED
x-client-CPU:REDACTED
x-client-OS:REDACTED
x-client-current-telemetry:REDACTED
x-client-last-telemetry:REDACTED
x-ms-lib-capability:REDACTED
client-request-id:REDACTED
return-client-request-id:REDACTED
x-app-name:REDACTED
x-app-ver:REDACTED
Content-Type:application/x-www-form-urlencoded
x-ms-client-request-id:71625b4f-01cf-4303-ba75-14d2395837bd
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Identity/1.10.3 (.NET 8.0.1; Microsoft Windows 10.0.22621)
client assembly: Azure.Identity
Connect-MgGraph: Entry point was not found.

Module Version
Microsoft.Graph.Authentication: 2.13.1
Az PowerShell module release version is Az 11.3.0

  • Az.Accounts: 2.15.1
  • Az.KeyVault: 5.2.0
  • Az.Resources: 6.15.1

Environment Data
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions