Recently I was asked to add a post about web hooks.
Thanks for taking the time to reply, I would love to see a STEP BY STEP implementation of a webhook specially how to automatically renew the expiry date of a subscription on a list. Azure functions implementation would be great.
So in this post I will attempt to answer the first part of the question from Keshav Taurah. Creating PowerShell Function Apps triggered by the creation of documents in SharePoint.
I will attempt to trigger a PowerShell script that is triggered by creating a SharePoint list item. While the web hook will renew the expiry date while it is being called.
First I’m going to reuse some of my work with Azure function apps that I created in one of my previous post:
But this time I’m not going to use time as a trigger but the creation of a list item.
The above dialogue is slightly confusing. Did I just select Webhook and CSharp? Where is the PowerShell option?
You will have to click on the blue hyperlink, create your own custom functions and then filter by Language:
Ok, we want to go for HttpTrigger here.
Make sure that the Authorization is set to anonymous. Then click on create.
Once the Function is created, got to the Integrate options and select Selected Methods and untick all methods except for POST
Then go back to the function ( click on the function name in the left hand side and configure the function url:
This will give you a dialogue that gives you a url like this one:
keep a copy of the url that you get and we’re going to use this within Flow.
Creating a Flow in SharePoint
On a document library called Documents I’m now creating a flow which triggers on the creation of new documents being added to the library. Then a web hook is called (using the above url)
When checking in Azure I found that my function is called successfully:
So now my web hook is working.