Open rfolkers opened 3 months ago
Since the status of this issue is "needs Investigation" I just did some additional troubleshooting, the problem seems to be some missing dependency in the Function Runtime:
[2024-10-07T13:28:20.337Z] ERROR: Invalid JWT access token.
[2024-10-07T13:28:20.338Z]
[2024-10-07T13:28:20.339Z] Exception :
[2024-10-07T13:28:20.340Z] Type : Microsoft.Graph.PowerShell.AuthenticationException
[2024-10-07T13:28:20.341Z] TargetSite :
[2024-10-07T13:28:20.342Z] Name : DecodeToObject
[2024-10-07T13:28:20.345Z] DeclaringType : Microsoft.Graph.PowerShell.Authentication.Core.Utilities.JwtHelpers, Microsoft.Graph.Authentication.Core, Version=2.9.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[2024-10-07T13:28:20.347Z] MemberType : Method
[2024-10-07T13:28:20.348Z] Module : Microsoft.Graph.Authentication.Core.dll
[2024-10-07T13:28:20.350Z] StackTrace :
[2024-10-07T13:28:20.351Z] at Microsoft.Graph.PowerShell.Authentication.Core.Utilities.JwtHelpers.DecodeToObject[T](String jwtString)
[2024-10-07T13:28:20.352Z] at Microsoft.Graph.PowerShell.Authentication.Core.Utilities.UserProvidedTokenCredential.GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
[2024-10-07T13:28:20.353Z] at Microsoft.Graph.PowerShell.Authentication.Core.Utilities.UserProvidedTokenCredential.GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
[2024-10-07T13:28:20.354Z] at Microsoft.Graph.PowerShell.Authentication.Core.Utilities.AuthenticationHelpers.SignInAsync(IAuthContext authContext, CancellationToken cancellationToken)
[2024-10-07T13:28:20.355Z] at Microsoft.Graph.PowerShell.Authentication.Core.Utilities.AuthenticationHelpers.AuthenticateAsync(IAuthContext authContext, CancellationToken cancellationToken)
[2024-10-07T13:28:20.356Z] at Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph.ProcessRecordAsync()
[2024-10-07T13:28:20.357Z] at Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph.ProcessRecordAsync()
[2024-10-07T13:28:20.358Z] Message : Invalid JWT access token.
[2024-10-07T13:28:20.359Z] InnerException :
[2024-10-07T13:28:20.359Z] Type : System.IO.FileNotFoundException
[2024-10-07T13:28:20.360Z] Message : Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Het systeem kan het opgegeven bestand niet vinden.
[2024-10-07T13:28:20.361Z] FileName : Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[2024-10-07T13:28:20.362Z] TargetSite :
[2024-10-07T13:28:20.364Z] Name : GetAsyncEnumerableInterface
[2024-10-07T13:28:20.365Z] DeclaringType : System.Text.Json.Serialization.IAsyncEnumerableConverterFactory, System.Text.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[2024-10-07T13:28:20.366Z] Executed 'Functions.Time1' (Succeeded, Id=38a8fd80-611f-409e-b946-dd3d70c23b58, Duration=7203ms)
[2024-10-07T13:28:20.366Z] MemberType : Method
[2024-10-07T13:28:20.369Z] Module : System.Text.Json.dll
This issue is not new so it seems, but in this case the issue is isolated to only local function runtimes.
I tried the solution in that topic (switch to certain module version and ExtensionBundle) but no change.
Describe the bug
Connect-MgGraph in Azure Functions (locally with Vs Code) fails with error invalid JWT token regardless of using Accesstoken, certificate of clientsecret
Expected behavior
Succesful authentication
How to reproduce
Create an Azure Function (Powershell) in VsCode and provide connect-mggraph in the script (using accesstoken, client secret of certificate). The connection will fail with error invalid JWT token
The same code runs succesful outside the Azure Functions runtime
SDK Version
Microsoft.Graph.Authentication 2.x
Latest version known to work for scenario above?
1.28
Known Workarounds
Use version 1.x
Debug output
Click to expand log
```Configuration
Windows 11 X64 - clean install Name Value
PSVersion 7.0.13 PSEdition Core GitCommitId 7.0.13 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
Other information
No response