Tuesday, May 31, 2022

Dilemma of choosing .Net SDK to interact with SharePoint

Last year, I had written a post about the Dilemma of choosing .Net SDK for Azure ServiceBus Queue. This is another scenario where we have to think many times before choosing a .Net SDK for interacting with SharePoint.

Background

Historically SharePoint was used for content management. Normally an admin will do basic things to provision the site and add users. But all most everything is automatable as it is built on top of API. When it comes to invoking APIs, we can use raw HTTP requests or use an SDK to invoke the same.

Many SDKs are available for .Net applications. Trying to see what is for what. 

CSOM

This is the original SDK from Microsoft. It was an installer when it started back in 2010, but is now available via nuget. CSOM² stands for "Client Side Object Model". The CSOM seems still maintained and supports the latest .Net versions as well. But their documentation¹ says "We're no longer updating this content regularly. Check Microsoft Product LifeCycle..." Below is the screenshot of the package as of writing this post.
In the announcement to make this API .Net Standard compatible³, Microsoft clearly says to use Graph APIs when possible with the Graph SDK nuget package. Use this if the Graph API is limited in features.

Nugets

Status

Still maintained, new releases are coming but kind of retired and recommends using Graph SDK.

Microsoft Graph SDK

There are server-side API differences as well along with the client SDK changes. Earlier we had SharePoint API⁵ and now we have modern Graph API⁴. They are different APIs⁶. The main difference is Graph API is not just limited to SharePoint but applicable across Microsoft 365. Graph API can be consumed by Graph SDK for .Net to work with SharePoint Online. This Graph SDK is developed as open-source software but it is incomplete.

Nuget

Latest and supported. But incomplete. Use CSOM library when we hit incomplete feature. 

The PnP Story

Life should have been easy if we had to deal with the above 2 alternatives. But there is one more before we can complete it. The PnP SDKs. PnP⁷ stands for Patterns and Practices

These are pure open source community SDKs not directly supported by Microsoft and have no SLAs.

But we can see Microsoft as an active contributor and even aka.ms link. 

https://aka.ms/pnp/coresdk/docs 

PnP sites Core

This open-source library was created as an extension to the CSOM library. But this has grown in complexity and they started developing PnP Core SDK which is clean, lean, has better test coverage, etc. But it is incomplete like the Graph SDK that we saw earlier.

Please note the older SDK is "PnP Sites Core" and the latest SDK is "PnP Core". The word "Sites" in the middle is missing.

Nuget

Status

Archived in GitHub. Use PnP.Framework or PnP Core SDK

PnP Framework

The PnP Sites Core supports till .Net 4.6.1 only ie Windows only. Meantime, they created another open-source library names PnP.The framework that supports .Net Standard and latest .Net Frameworks and the .Net. 

The interesting thing is the PnP Framework nuget depends on the PnP Core SDK nuget.

Nuget

https://www.nuget.org/packages/PnP.Framework/

Status

Latest and supported but will eventually transition to PnP Core SDK.

PnP Core SDK

This is the real open-source successor⁸ in the PnP family. Try to use this if we ever want to use PnP SDKs. 

Nuget

Status

Latest and maintained. But incomplete.

The above image credits go to the PnP Sites Core repo that explains the roadmap.

Summary

This just introduces the most common options available. Very less details. As developers, we should always look at the Microsoft Graph SDK to achieve our goals. If not supported look at the other libraries.

Update 2023-10-05

There is documentation in choosing the right SharePoint API based on the client application. That is helpful if we want to work with SharePoint from non .Net applications or platforms other than Windows.

References

No comments: