pnp / PnP

SharePoint / Office 365 Developer Patterns and Practices - Archived older solutions. Please see https://aka.ms/m365pnp for updated guidance
https://aka.ms/m365pnp
Other
1.9k stars 3.31k forks source link

Sharepoint authentication issue from Azure function (.net Core) #1905

Open venkeykanle opened 4 years ago

venkeykanle commented 4 years ago

Hi Team,

At the outset apologies, if this is not the right group to address the issue.

Issue: Unable to authenticate the Sharepoint url from Azure function, while its works good in my local environment. Here is the code-snippet.:

using Microsoft.SharePoint; using Microsoft.SharePoint.Client; using SharePointPnP; / .... / string siteUrl = "https://abcd.sharepoint.com/xyz/abcd123"; string clientId = "aaaaa-bbbbb-ccccc-ddddd-eeeeeeeee"; string clientSecret = "lalalalalalalalalalalalalalalalalalall=";

var clientContext = new OfficeDevPnP.Core.AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, clientId, clientSecret);

The last line throws error.. Works good in local (.Net frame work 4.x) and but fails to authenticate in Azure function (.Net Core 2)

Is there any alternative PnP in Azure function on .Net Code2.1? Would be great if someone throw lights on correct Assemblies to be used or some solution.

Thanks, Venkatesh Kanale

dnyaneshwar-surywanshi commented 4 years ago

Hi I am also using same code and my targeted version is .Net Core 3.1 getting below error : The type initializer for 'OfficeDevPnP.Core.Utilities.TokenHelper' threw an exception. ---> System.TypeLoadException: Could not load type 'System.Web.Configuration.WebConfigurationManager' Please help me on this.