Back to previous page

How to Create a Function App to Communicate into a SharePoint Site

Log In to Watch How to Video Now
How to Create a Function App to Communicate into a SharePoint Site


Join Eric Overfield, Microsoft Regional Director, MVP, PIXELMILL, USA on How to Create a Function App to Communicate into a SharePoint Site. The short tutorial will help you jumpstart your next SharePoint project using future friendly provisioning methodologies.

 

Video Transcript:

I mentioned that site scripts include a verb or an action which is trigger flow it allows us to trigger a flow within within our tenant a really common use case here is that the flow will actually execute an agile function and the reason why you might do this again is because there are certain things that side scripts still can’t do such as add content or add pages so if you create a site design you’ve now got a user interface based way for your users your end-users to be able to create SharePoint sites they can create your team sites and comp sites and whatnot in the UI they don’t need any kind of PowerShell commandlets or code or anything like that but one of that actions could then be to trigger an Azure function and now the azure function can go in and do things maybe that your side scripts can’t do or maybe there’s some line-of-business aspects or components or code that you need to have executed the trigger flow provides us that functionality it’s pretty easy to do and set up basically have a verb it’s trigger flow you give it the URL to the flow and you need to send along some very specific parameters all of that is documented on the URL that I provided here over on Docs tell Microsoft comm how this works the idea here is that when your site is being provisioned on step one that that trigger flow action is then executed that then it uses the URL the flow to execute the flow the most simple use case is basically your flow does one thing it grabs the request and it posts the URL of the site that was just created because that’s the one thing that the trigger flow does is it basically provides the URL of the site that was just created to the flow your flow can then take that URL and put it into an add your storage queue that’s it just the URL of the newly created schema.json site on a storage cube you could then create an azure function and that as your function is tied to the storage queue so anytime anything is added to the storage queue in Azure your Azure function will then get fired your Azure function can now take that URL and do whatever does you need to do you can just you can use that URL you can now connect to SharePoint online you can connect to that site and you can do things like apply maybe a PPA provisioning template and it works pretty well pretty easy all right so let’s look at that this one’s gonna get a little a little more complex because just we have a lot of moving pieces but let me kind of show you the important stuff here let’s first get first of all go ahead and let’s look at the flow in question because I’ve already said a lot of this stuff up let’s go ahead and let’s go here to flow perfect up so I’ve got a couple flows already created the one I care about here is this bottom one and you can just create the flow yourself basically it’s a very simple flow I told you it was simple if we go ahead and we edit the flow it does two things when it HTTP request is received so here’s that URL that my site script is going to execute on the trigger flow action I needed a schema and the schemas provided for us basically in the documentation because this is what the site script is going to be sending into the flow that’s it so when an HTTP request was received do something what is it we want to do we just want to put a message on a storage queue that’s it so we do need a storage queue of course that’s half that happens over in storage accounts now I have a the story already created here I mean you can see that the delays is taking me that I’ve had to create all the stuff to politic except you know a couple hours to get through all the demos so I’ve already created all these things all of this is documented everything I’m doing here is documented in the links that I provided by the way so you can spend the time it will take to sort of walk through all these steps but at least you’ve now seen the overall process but there are queues that you can add in a storage queue and one of them is that I’ve created is just this dev one test prox queue one storage queue and if we go back to flow we will see that’s the exact same storage queue that I’m connecting to and all I’m doing is I’m putting the web URL on that in that queue so now I’ve got an azure function that I’ve created as well that is tied to that storage queue so we’re going to go back to function Apps here we’re going to the I have a different function app that I created for just that storage queue it’s also named q1 within that there will be a function that will load up eventually and that function will is tied to that storage queue so anytime that that storage queue gets a new a new entry it will go ahead and it will execute that and in interest in time because I always run out of time because I have so much fun stuff that I want to share there it goes I’ve got us a Azure function again this is using PowerShell this one is significantly more simple than my other one basically it’s just getting the input it’s connecting to SharePoint and it’s applying a provisioning template to that URL so this would be a this would be an azure function that is going to get triggered by flow and that flow is being triggered because of a specific site script action that I created so let’s go ahead and let’s look at what that might look like so here is the that that that site script that I want to run you can see the verb trigger flow then the URL and whatnot that I want to provide so let’s go ahead and let’s load that into memory let’s go ahead and let’s add a new site script and let’s go ahead and let’s create a new site design that is executing that site script so I have a new site design that should be custom team site design with flow so let’s go ahead and let’s create a new site for us let me just quickly grab that URL and put that here and what we’re gonna do now is once it loads we’ll go to create site we’re gonna create a team site eventually this is definitely not loading as quick as it has in the past there we go and I should now have a site design perfect my custom team site design with flow has been created so let’s go ahead and we’ll say ESPC web in our demo with flow a lot a little space there because makes me feel good excellent it doesn’t matter it’s private here but this time we want was private and once this is created let’s go ahead and click on finish and this will load up our site for us and we will we should see on the right hand side we’ll get that that window that appears now while that’s happening I’m gonna go back to flow and what should happen is in the run history two seconds ago not that so it looks like our flows succeeded two seconds ago if we actually go here and we look at our logs this hasn’t executed yet because I wasn’t paying attention okay it’s still perfect so it did trigger the flow and it added the event if I go to view updated site what we should see here now so the flow is stilted looks to be running the adder function what  happens is the provisioning script that Iran is let’s see if I can quickly find that provisioning script for us the provisioning script that I ran all it’s supposed to be doing is it’s creating a new page so here’s a much more sophisticated provisioning script it’s creating a new page called home PNP aspx that is a modern page it’s creating sections there it goes functions completed so now if we return here and we return to the home page what should happen is our home page should now be home there goes home P and P you can see it and now you can see I have a very different home page it’s loading you can already tell the text so not too bad if you think about it that you can use PP provisioning to set up new home pages you can build pages using your custom and out-of-the-box web parts and you can pre configure them to do some really cool stuff

Share this on...
Log In