0

I'm developing a simple Azure Function project that uses the NuGet package Microsoft.NET.Sdk.Functions (version 1.0.29) to trigger on incoming Azure Storage Queue message, and uses SharePointPnPCoreOnline (version 3.15.1911) to communicate with SharePoint Online.

I seems like the current version of Microsoft.NET.Sdk.Functions does not play well with SharePointPnPCoreOnline, because the former is dependent on Newtonsoft.JSON version 9.0.1, while the latter requires Newtonsoft.JSON >= 11.0.1.

I've tried setting up an Azure Function v1 (which is based on .NET Framework), but this causes my project not even to build:

Error NU1107 Version conflict detected for Newtonsoft.Json. Install/reference Newtonsoft.Json 11.0.1 directly to project FunctionApp5 to resolve this issue.
FunctionApp5 -> SharePointPnPCoreOnline 3.15.1911 -> Newtonsoft.Json (>= 11.0.1)
FunctionApp5 -> Microsoft.NET.Sdk.Functions 1.0.29 -> Newtonsoft.Json (= 9.0.1).

I found a workaround suggesting I could explicitly set the Newtonsoft.JSON version to an older one (in this case 10.0.2), like this:

Doing this still causes my project not even to compile:

Warning NU1608 Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.29 requires Newtonsoft.Json (= 9.0.1) but version Newtonsoft.Json 10.0.2 was resolved.

Another attempt was to base my project on Azure Function v2 (which is based on .NET Core). This causes runtime errors, so I believe SharePointPnPCoreOnline may not be compatible with .NET Core:

System.MissingMethodException HResult=0x80131513 Message=Method not found: 'System.Runtime.Remoting.ObjectHandle System.Activator.CreateInstance(System.String, System.String)'. Source=OfficeDevPnP.Core StackTrace: at OfficeDevPnP.Core.Diagnostics.Log.InitializeLogger() at OfficeDevPnP.Core.Diagnostics.Log.Debug(String source, String message, Object[] args) at OfficeDevPnP.Core.AuthenticationManager.EnsureToken(String siteUrl, String realm, String appId, String appSecret, String acsHostUrl, String globalEndPointPrefix) at OfficeDevPnP.Core.AuthenticationManager.GetAppOnlyAuthenticatedContext(String siteUrl, String realm, String appId, String appSecret, String acsHostUrl, String globalEndPointPrefix) at OfficeDevPnP.Core.AuthenticationManager.GetAppOnlyAuthenticatedContext(String siteUrl, String appId, String appSecret) at AzureFunction_v2App.Function1.Run(String myQueueItem, ILogger log) in [snip]

Have anyone gotten Microsoft.NET.Sdk.Functions and SharePointPnPCoreOnline to play nicely together, and could perhaps share some insight on how to set up the project?

4
  • did you got a resolution on this? Feb 21 '20 at 23:26
  • @RaviKhambhati Unfortunately, no. I decided not to spend any more time on this, but find some other way to piece things together.
    – kenneho
    Feb 23 '20 at 17:30
  • Thanks @kenneho Can I ask what approach you have finally opted ? Feb 24 '20 at 17:02
  • @RaviKhambhati, I decided to run the code on an on-premise server instead of in Azure Functions. This way I didn't have to fight the incompatible libraries.
    – kenneho
    Mar 10 '20 at 6:21
0

You can set the version of Newtonsoft.JSON to 11.0.2. This will prompt warnings but it could compile and the project could work.

Please take a reference of below demo that I tested on my Azure tenant.

BR

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.