Introduction
In this article, you will learn how to create Azure function apps for SharePoint operations, using PnP Core CSOM library components.
Azure functions are the ways to run the solutions or pieces of code over the Cloud. It helps in processing the data or integrating other systems or even working with the Internet of Things.
The main advantage of using PnP Core libraries will be the reduced code to get the required information. The required object can be retrieved with just single line of code, once the client context is set. PnP core CSOM documentation can be found on Office site here. PnP Core CSOM library packages can be downloaded here.
The references used for testing the sample are given below.
- Microsoft.SharePoint.Client.
- Microsoft.SharePoint.Client.Runtime.
- OfficeDevPnP.Core.
The functions can be triggered in multiple ways. Here, we will create HTTP trigger function. More details and pricing information about the Azure functions can be found here.
The articles given below also shows step by step approach in integrating SharePoint operations on Azure functions.
- Microsoft Azure account with Azure functions app.
- SharePoint online portal
From Azure portal, create new Function app.
Under Function app, create new function, using HttpTrigger-CSharp template (If the template is not listed, select all the options from the language and scenario dropdowns).
Importing SharePoint Assemblies
By default, only the system assemblies are present on Azure functions. To load the external assemblies, we need to import the assemblies into the function and then reference it in the code. SharePoint PnP Core CSOM core assemblies need to be uploaded.
The assembly files are extracted by from NuGet site. Follow the site given below to extract the required assemblies.
Upload the required assembly files, using Kudu tool. From the app settings page, select advanced tools under development tools and click on go. The tools page will be opened. Under debug console, select PowerShell. Navigate to the appropriate function under wwwroot folder. Create the bin folder and upload the necessary files. Please refer to my previous articles for step by step approach.
Note- If the deployment credentials are not set, then set the credentials from the app settings page and then proceed uploading the assemblies.
Go back to the created trigger function. Write the necessary code in run.ps1 file under develop section.
Refer the assembly files, using #r and using keywords. Now, start writing the necessary code for the execution.

Join the conversation! Your thoughts help the community grow.