One of the biggest announcements during Ignite 2017 for SharePoint was probably the upcoming availability of Site Designs, giving us the option of customizing a Modern Site while still using the out of the box site creation experience. End-users can simply select the wanted template, also Site Design, from a dropdown, enter a title and within a few seconds the new site has been created. After the site has been created a template is provisioned onto this new site, effectively updating it. At the moment of writing this blog, this template can only include custom lists and columns, a theme and a call to a Flow. In the future the template will probably contain more options, as the Microsoft Development team continues to enhance it, but for now extra actions need to be done via Flow. The template’s accessibility can be restricted to users or usergroups, giving you the option to hide templates from employees.
How do Site Designs work?
When a user creates a new Modern Site using Site Designs, they enter a title and a description and click ‘create’. SharePoint now creates a new Site Collection for this user like before. Because the SharePoint Online team has spent some time with the Azure infrastructure team to tweak performance the site is now created in 2 or 3 seconds, which is obviously a lot quicker than before! When the site is created, the user can add additional site members just like before. After that, they are redirected to the new site and the template provisioning is kicked off. You can see the progress in the right sidebar, showing a neat list of created lists and columns and whether a Flow is started and executed successful. The final step is activating any custom theming and then the site is done. When the user clicks finish, the page will reload and show the customizations.
The real magic, for now, happens in the flow. Although it’s really nice to be able to create a template and push it to a select group of users via the out of the box experience, we of course want to be able to tweak the site completely!
Microsoft Flow & Azure Functions
During the template provisioning, a call is made to a custom Flow. This Flow is of the type ‘HTTP receiver’ and can be called via an URL. After you create the flow, you can copy its URL from the GUI and use it in the template of your new Modern Site. Because it’s Flow, we can then leverage all the options it has to offer during our Site Creation process such as sending an email, creating a log-item in a SharePoint list or adding items to a Storage Queue for use in an Azure Function.
In this Azure Function we can use, for instance, the PnP Provisioning engine in C# or PowerShell for additional templating capabilities to the site creation. Because we are in a Queue function we need an App Secret and App Client ID to access the new SharePoint site, this will need to be an App added at tenant level with admin scope permissions to do so. The URL of the newly created site is passed along from the provisioning to the Flow, to our Azure Function. When we have a ClientContext for the new site we can perform any action on it via CSOM/PnP, and of course run any other useful C#/PowerShell code. When the new Site Designs functionality is in preview, I will write a more complete guide on how to do this, or point you to Microsoft’s MSDN page.
Effectively all of this means we can now completely customize any Modern Site through the default, out of the box, experience in SharePoint. Something that hasn’t been an option in SharePoint Online before.