Remote Site Provisioning with SharePoint Online and PnP

An introduction to the SharePoint Patterns and Practices (PnP) library – discover how how it can be used to power remote site provisioning.

With many organisations now moving, fully or partly, to Office 365, the way solutions are developed is evolving rapidly. In this series of blog posts, I’m going to share some of the more innovative tools available in Office 365, and the support Microsoft offers those who want to work at the cutting edge.

In this post, I’ll look at a very common requirement – SharePoint site provisioning. Site provisioning is the software-assisted creation of SharePoint sites, with certain elements already set based on default values. The business benefits to providing a site provisioning toolset include:

  • Helps prevent site sprawl, ensuring sites are only created when and where they are needed.
  • Users can create sites in a more consistent manner. This includes consistency in Permissions, List, library, and Folder names, Navigation and Metadata.

With an on-premise set-up, developers have multiple options available to them for provisioning new sites – site definitions, web templates, features (with feature receivers), web services, and so on.

When it comes to Office 365, though, there is only one supported way: remote site provisioning.

What is Remote Site Provisioning?

Remote site provisioning is the way to programmatically create SharePoint sites from any computer other than the server the SharePoint farm is hosted on.

The simplest form this can take is setting up a SharePoint provider-hosted add-in, hosted as an Azure web site. This approach uses the SharePoint add-in model, and the existing functionality around setting up add-ins, trusting them, and accessing them using an access token.

What is PnP – and why do we need it?

Patterns and Practices (PnP) is a code library created and maintained by Microsoft that builds on and extends the SharePoint Client Object Model. This library focuses on providing the core actions that many SharePoint developers might need while interacting with the Client-Side Object Model (CSOM). It also has a core focus on site provisioning.

Because it’s a library, PnP doesn’t come with any user interface, or any advanced functionality of its own. That means that while it is very powerful, on its own PnP is as useful to end-users as a chocolate teapot.

What it does offer is a large set of sample projects showing off its features, and some common use cases. Some of these samples are very useful, but due to the pace of change they can quickly become out of date (and the approach they suggest doesn’t always work with the modern SharePoint experience).

PnP is maintained and tested by many professionals, making it an accelerated starting point that also benefits from monthly updates. However, since it lacks a user interface, can be buggy, and makes some assumptions around what should or shouldn’t be included when sites are provisioned, PnP can’t be used on its own as a remote site provisioning engine.

That’s where ProvEn comes in.

Provisioning with ProvEn

ProvEn is CompanyNet’s smart remote site provisioning engine, which runs as a subscription service in the cloud. ProvEn takes advantage of the cutting-edge Azure stack, using services such as queues, web jobs, Logic Apps, Azure storage and web slots.

With the latest PnP library baked into its core, ProvEn not only provides a rich user interface to PnP, but also builds on its set of features. ProvEn supports not only creating new sites – which is part of PnP – but also updating existing sites, which isn’t.

When you are creating a site or updating a site the following steps are run by ProvEn:

  • Check that the site collection is correctly configured to support this template;
  • If the site doesn’t exist, create the site;
  • Get and Apply the site template;
  • If default metadata needs to be set, create additional columns on libraries and setup default metadata;
  • If a Yammer group is required, create one and embed it on the homepage;
  • Create a Site Information list to enable the site to be surfaced in search and to support site classification;
  • Apply a site policy;
  • Once everything is completed, notify the user that requested the site.

Since PnP is a perpetual work-in-progress, we monitor the monthly changes to this library (plus any unexpected ones), and incorporate them back into ProvEn.

If you are working with PnP, there are a couple of things to bear in mind:

  • Issues with PnP are logged via Microsoft’s Github site; should fixes be released, they are included in the monthly drop. It’s vital to keep an eye on this to decide if you need to upgrade the PnP version you are using.
  • Sometimes PnP will behave in a way that seems counterintuitive. In these cases, you might submit an issue on Github, but the PnP team will reject it as, in their view, it’s working as expected. If this happens, you may need to code ‘around’ the problem to achieve a particular goal, diverting your app away from PnP to your own code for a particular function.

As an end-user, you don’t need to worry about what’s happening in PnP – by using ProvEn, you can be assured you’re always taking advantage of the latest and greatest site provisioning features.

In summary, remote site provisioning can make your life significantly easier; Microsoft’s PnP library provides innovative ways to manage SharePoint sites, but without a front-end interface it’s not much use to normal humans. That’s why we’ve created ProvEn, which provides an intuitive experience that unlocks the power of PnP for everyone.

In my next blog post, I’ll consider the options available when you’re looking to extend PnP.

Does your organisation need a better way to provision SharePoint sites? Check out ProvEn, our smart site provisioning engine.

Share this page

Leave a comment