CSOM vs PnP Core inside our Azure Functions

john john 946 Reputation points
2023-01-26T22:01:50.6633333+00:00

I want to write an Azure Function deployed inside Azure and which run on timer schedule. but i am not sure which library i should user, either:-

  1. CSOM
  2. PnP Core

what are the main differences and when you use each?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,737 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,686 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rob Windsor 1,956 Reputation points
    2023-01-27T13:11:35.9+00:00

    PnP Core is a library that sits on top of Microsoft Graph, the SharePoint REST API, and CSOM. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying APIs being called.

    So, the developers of the API have figured out which of these APIs can perform which set of operations so that you don't have to. It's my understanding that the team working on PnP Core try to implement each operation using Microsoft Graph first, then they fall back to the SharePoint REST API, then the fallback to CSOM.

    The benefit of the abstraction layer is that as new capabilities are added to Microsoft Graph, the PnP Core team can switch out the internal implementation of one or more operations without affecting consumers of PnP Core.

    Getting back to your original question, I think the choice to use CSOM or PnP Core or Microsoft Graph or the SharePoint REST API is up personal (or development team) preference. I don't think there's a right or wrong answer.