I am trying to write a function app that uses the Graph SDK. I have declared dependencies on:
- Microsoft.Azure.Functions.Extensions 1.1.0
- Microsoft.Graph - 4.1
- Microsoft.Graph.Auth - 1.0.0-preview
- Microsoft.Net.SDK.Extensions - 3.0.13
When I try to run a test request, I get the following error:
An exception of type 'System.IO.FileNotFoundException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Could not load file or assembly 'System.Text.Encodings.Web, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.'
at System.Text.Json.JsonSerializerOptions.GetWriterOptions()
at System.Text.Json.JsonSerializer.Serialize[TValue](TValue& value, Type inputType, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
at Microsoft.Graph.Serializer.SerializeObject(Object serializeableObject)
at Microsoft.Graph.BaseRequest.<SendRequestAsync>d__40.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Graph.BaseRequest.<SendAsync>d__34`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at {<!-- -->{my code}}
There are clearly two different versions of System.Text.Encodings.Web being declared by the packages I am using.
If I try to update my .csproj file to explicitly reference 5.0.0:
<PackageReference Include="System.Text.Encodings.Web" Version="5.0.0" />
I get the following compile time error:
[...]\source\API-AzureExternalIdentity\API-AzureExternalIdentity.csproj : error NU1605: Detected package downgrade: System.Text.Encodings.Web from 5.0.1 to 5.0.0. Reference the package directly from the project to select a different version.
[...]\source\API-AzureExternalIdentity\API-AzureExternalIdentity.csproj : error NU1605: API-AzureExternalIdentity -> Microsoft.Graph 4.1.0 -> Microsoft.Graph.Core 2.0.1 -> System.Text.Json 5.0.2 -> System.Text.Encodings.Web (>= 5.0.1)
[...]\source\API-AzureExternalIdentity\API-AzureExternalIdentity.csproj : error NU1605: API-AzureExternalIdentity -> System.Text.Encodings.Web (>= 5.0.0)
I tried using the Modules panel in Visual Studio to figure out which version of System.Text.Encodings.Web is actually being loaded (as described in https://michaelscodingspot.com/how-to-resolve-net-reference-and-nuget-package-version-conflicts/), and, uh... what it showed me was that I'm using version 4.700.21, which doesn't exist anywhere that I've been able to look.
What combination of packages do I actually need to use in order to use the Graph SDK in a Function App that is using the DotNet Core 3.1 runtime?