Closing this message and/or accessing our website tells us you are happy to receive all cookies on the ClearPeople website.
However, if you would like to, you can change your cookies settings at any time.
I would like to show you how to use Azure Functions along with SharePoint WebHooks. Besides, I will show you how to use environmental variables (app settings) and code from external libraries (like the PnP Core) within the code of your Azure functions.

In this first post, I would like to show you how we can use Azure Functions as service endpoints for the SharePoint Webhooks subscriptions. I’ll guide you through the process to create a function and I will show you how to form the url that you must set as the endpoint in a webhook subscription.

I’m not going to explain how SP Webhooks work in this post, but you can visit this link for a better understanding of what SP Webhooks are.

To begin with, you are going to need to create a “Functions App” in Azure. To do this, enter to the Azure Portal and look for “Function App” in the Azure Marketplace:


What you are doing is to create a special kind of App Service, but there is an important thing to notice. If you choose “Consumption Plan” as your Hosting Plan, you will pay only for the time that your functions are being executed. This is an interesting feature of the Azure Functions and it’s worth to use it.


Now if you open the “Function Apps” blade you will find your app in there:


In my case, I’ve created an app with the name “cpichesafunctions”. If you click in the app a “+” button next to the “Functions” will appear. Click on it and choose a template to start. Notice that you can create functions using different programming languages. This time, I’m going to choose C# as the language to use and I want a function of the kind HTTP trigger (there is a “GenericWebHook” template, but it doesn’t work good with SP WebHooks, however, this is just a template and you will write the code that you want). It is important to select “Anonymous” as the authorization level because SharePoint needs it.


Next step is to configure your function (mine is “spwebhookfunction”). Click on “Integrate” and modify “Allowed HTTP methods”, “Mode” and “Selected HTTP methods” like in this image:


Finally, you need the url that you are going to use as the webhook service endpoint. Click on your function to see the “workbench” screen. The code you see in there is the example that the template auto-generates (You will need to modify this to handle SharePoint notifications).

Click on “</> Get function URL” to see the url of your function, copy it in a notepad and add “?code=” at the end:


Now click on the “Manage” button of your function and in the “Function Keys” section click on the “Click to show” link next to the “default” key to see the key:


Add this key at the end of the url that you pasted in your notepad (the key is used to avoid unauthorized usage). What you have is the endpoint url that you must use for your webhook subscription and it should look like this:

In the next post, I will show a functional code example to be used as webhook service endpoint and I will explain what you must do to use environment variables (app settings) and external libraries in your Azure Functions code.

Author bio

Ivan Chesa
Ivan Chesa
Junior Developer
I’m part of the SharePoint development team. Besides working on client and internal projects, I enjoy learning more about other technologies like Azure. In my spare time I love playing video games with friends and I also like to watch TV shows.


comments powered by Disqus

Related Articles

Sign up to our Newsletter ClearThought

Get inspired and learn something new by subscribing to our FREE bi-monthly newsletter. It’s full of ClearPeople's thought leadership whitepapers, blogs, events, and much more.
We promise to not use your email for spam.