Azure Functions For SharePoint Operations Using PnP PowerShell


In this article, you will learn how to create Azure function apps for SharePoint operations, using PnP PowerShell commands.

Azure functions are the way to run the solutions or piece of code over the Cloud. It helps in processing the data or integrating other systems or even working with the internet of things. 

PnP PowerShell modules

The main advantage of using PnP PowerShell over CSOM PowerShell will be the reduced code to get the required information. PnP PowerShell assemblies can be extracted from the installers. To test PnP PowerShell commands on the local machine, the installers are available on the official site here.

Once installed, the assemblies can be extracted from the local paths (mostly the modules will be present here C:\Program Files (x86)\SharePointPnPPowerShellOnline\Modules\SharePointPnPPowerShellOnline).

In this sample, let us see how to integrate SharePoint operations on to Azure functions app, using CSOM PowerShell. Any complex code (CSOM) can be written and executed on Cloud.

Functions can be triggered in multiple ways. Here, we will create HTTP trigger function. More details and costing information about Azure functions can be found here

The assemblies should be uploaded to Azure function app repository, which will be explained later in this article.

To start with, I have created a simple azure function, which retrieves total Web features count from the site.


  • Microsoft Azure account with Azure functions app.

  • SharePoint online portal.

Create Function App

From Azure portal, create new function app.

Under function app, create new function, using HttpTrigger-PowerShell template (If the template is not listed, select all the options from the language and scenario dropdowns). 

Importing SharePoint assemblies