msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Connect-Graph : Method not found: Void Azure.Core.TokenRequestContext..ctor
Describe the bug
I am trying to connect to the Graph API with Connect-Graph command using the client secret credentials flow.
This worked fine as I was developing it earlier this week on v2.18.0. I then configured the scripts on our Jenkins server where our admins installed Microsoft.Graph v2.19.0. No prior version of Microsoft.Graph had ever been installed on that server. The error occurred on the server first. So then I attempted to replicate the issue and installed v2.19.0 on my machine and successfully replicated it. However, the error does not go away when I revert to v2.18.0.
I figured there was a version conflict going on so I've tried many times, using many methods to uninstall all versions of the Microsoft.Graph* modules, then re-install v2.18.0 but so far no change. I always get that same error now.
I assume this is probably an issue with my environment somehow and most likely not a bug but I figured I would share here in case anyone else has encountered this with v2.19.0 or has any suggestions as to what might fix this.
Expected behavior
Connect to the Graph API and get the normal welcome message
How to reproduce
Since I can't get to the prior working state, I don't have a list of steps to reproduce as noted in my description above.
SDK Version
2.19.0
Latest version known to work for scenario above?
2.18.0
Known Workarounds
None at this point
Debug output
Adding -Debug
did not result in any extra useful output unless there is a log file somewhere that I'm not aware of.
Configuration
My machine: Windows 10
PS C:\Develop\SharepointDataExchange> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.4291
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.4291
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Other information
No response
I'm having the same issue and it appears to only happen when the Az module is installed.
Hm. I do not have the Az module installed.
I've done a bit more digging and found that the Azure.Core assembly that gets loaded into my PowerShell session is the wrong version. I ran this script to identify where all the loaded assemblies originate from (credit this post):
[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location, GlobalAssemblyCache, IsFullyTrusted | Out-GridView
This yielded:
As you can see, the Azure.Core assembly is actually loaded from the SqlServer module and is version 1.25 instead of 1.38 (the version that comes with the Microsoft.Graph.Authentication module).
Next step is to figure out how to remedy this...
The simple solution was to import the Microsoft.Graph.Sites module before the SqlServer module. This causes the correct version of Azure.Core to load first.
This exhaustive post on Resolving PowerShell Module dependency conflicts was helpful.
Thanks for confirming!
We were able to remediate a similar issue in Az #2703
We can close this issue here given there is nothing we could do differently in SDK, OK?
I just hit this bug today with whatever version is in PSGallery right now, on Powershell 5.1.
We've had issues with this ever since MS.Graph v2.9.0, and every once in a while we check to see if it still persists, but so far it hasn't been fixed.
This issue still exists in version 2.23.0. Can you please reopen this issue @petrhollayms, @timayabi2020?