I'm running into some trouble when trying to get a client context from PnP for an Azure AD app only connection.

I'm trying to follow This tutorial on how to create an application that would run on a SharePoint tenant with DisableCustomAppAuthentication on.

Unfortunately I fall short when it comes to retrieving the client context from Azure in c#. Exactly at this point:

public class CustomAuth
    public static ClientContext GetContextObject(string siteUrl)
        string _clientId = ConfigurationManager.AppSettings["ClientId"];
        string _clientSecret = ConfigurationManager.AppSettings["ClientSecret"];
        var authManager = new AuthenticationManager("********-b7a4-4d80-8254-920df9b5df4e", "c:\\dev\\cert.pfx", "******", "mytenant.sharepoint.com");
        var context = authManager.GetAzureADAppOnlyAuthenticatedContext(siteUrl);

        context.Load(context.Web, p => p.Title);

        catch (Exception e)

        return context;

It seems that the authentication manager does not contain the GetAzureAd function. I tried with GetContext instead, but it just loads indefinitely.

I'm on .net 4.7.2 , the NuGet for PNP.Framework is on 1.10 and PnPCore is on 1.7.90. Do I need to upgrade .net for it to work ?

1 Answer 1


As per the PnP Framework GitHub page,

PnP Framework is a .NET Standard 2.0 / .NET 5.0 / .NET 6.0 library targeting Microsoft 365 containing the PnP Provisioning engine

Try using these:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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