PnP Partner-Pack Site Provisioning: Weirdness, quirks and guide

If you have been playing around with the Site Provisioning in the PnP Partner Pack you might have run into problems when installing it. While the instructions are rather good there are still some problems which I ran into and are not mentioned in the instruction(or I might have just passed by them).

Notice that the things mentioned here assumes that you have read or understand how to install the site provisioning web app by this instruction:

Anyway here is what is good to know:

Sign-ON URL format:

When you are defining your Sign-On URL in the Configure section for your application, there is a very weird and annoying error that the site provisioning web application might throw. This is due that you are missing one single character from the end of your URL which is: /


URL which does not work:

URL which does work:

Do you see the difference :)? Small but enough to make you wonder. The error message is not necessarily very informative and unfortunately I do not have that error message anymore, can paste it here. Just check this thing in case of errors.

The webjobs…:


The web jobs are good and working BUT the installation is a bit misleading. I had to figure out for myself and gather the info from different locations. My problem was that the script which was supposed to install the jobs automatically did not work. Some error which did no make sense and I did not want to spend time figuring out. If it works for you then that is great. If not you might have to do this manually.

You have different way on how to do this manually:

  1. Through Azure portal management
  2. Through visual studio


Azure portal management

  1. Build a release version of the webjob
  2. Just zip the entire release folder and rename your zip package
  3. Go to your web application web jobs section
  4. Click add a new job and upload your ZIP file and define how you want your job to run


Visual Studio

On the web job project which you want to upload to Azure press the second button and chose  “Publish as Azure Webjob” and follow the instructions.

You might want to take advantage of the Azure management UI by downloading a publishing profile from your web application dashboard. You can use this publishing profile in Visual Studio.

The webjobs what they do


This is the one which will be reading the PnPProvisioningJobs list and create jobs to be processed by the other webjobs. You have to have this on to get anything done, mostly related to site provisioning. I might be wrong on some of the details here but having this on is essential.


My understanding is that his job is what is provisioning the sites and creating templates of sites.


Guide – What is where or how things work

The web application overall UI functionality

As is mentioned in this documentation there are several views(pages) which are used with the site provisioning. Notice that not all of them are available through the web application UI and this in my opinion is confusing.

Some of the functionalities are only available in a actual site:

  1. Creating a new sub site
    1. This is only available when you go to a site, from “site settings” select “site contents”. The PnP Partner Pack overrides the default “New subsite” link. I kind of understand this but was not the first place where I expected it to be.
  2. Saving a site template
    1. This can be found under your site “site settings” in the category “site actions”. There is a JS file which is attached to your PnP sites which add a new link here named as “Save site as Provisioning Template”.

The JS file is located in the infrastructure site in the Library: PnPProvisioningTemplates under the folder: Overrides. Through the XML file in this location the JS file is loaded and the two above mentioned things are performed.

Infrastructural Site Collection

What is mean by this is that this is a “dummy” site collection created by you and then you apply the steps(script) on the site collection. This will be the central hub from where all things are operated from regarding site provisioning.

Good to know libraries


This is where your site provisioning templates are located(right in the root of the library) and all other PnP site provisioning related configuration data.


This is all of the actions(jobs, requests) for sub site, site collection, site templates etc are stored. Based on these the web jobs will start to operate.


How to set O365 PageLayout Associated Content Type field

Here is a code snippet to set your page layouts associated content type. This one was a bit weird when I first tried to set it.

 private static void SetPageLayoutMetadata(Web web, File uploadFile, string title, string publishingAssociatedContentType)
// Speficy that the page layout is a page layout and not a master page
var parentContentTypeId = ""0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE811""; //Page Layout
var gallery = web.GetCatalog(116);
web.Context.Load(gallery, g => g.ContentTypes);

var contentTypeId = gallery.ContentTypes.FirstOrDefault(ct => ct.StringId.StartsWith(parentContentTypeId)).StringId;
var item = uploadFile.ListItemAllFields;

item["ContentTypeId"] = contentTypeId;
item["Title"] = title;
item["PublishingAssociatedContentType"] = publishingAssociatedContentType;


Two important things:

  • parentContentTypeId: This is the ID that tells O365 that this page layout is actually page layout, this is a static id which is defined in the code
  • publishingAssociatedContentType: This is your actual content type to which you want to associate your page layout to: Example of the format:;#my content type name;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D00A3428808D7DE6A4RABF83921AFB25424;#
    • So the format should be in the following way:

public static String BuildPublishingAssociativeContentTypeId(ContentType contentType)
String contentTypeAssociativeID = null;
if(contentType != null)
contentTypeAssociativeID = String.Format(";#{0};#{1};#", contentType.Name, contentType.StringId);

return contentTypeAssociativeID;

O365 OfficeDev PnP CSOM tools installation

This post will assume you have Visual Studio installed with Microsoft Office 365 API tools for Visual Studio.

  • Create a new Visual Studio project, lets say a console application.
  • Press on your project the second mouse button and select “Manage NuGet Packages…”
  • In the new window search for online packages and type in pnp or officedevpnpcore or similar. Then install the OfficeDevPnp.Core.Online package.


  • Wait for the installation to complete. After this you are ready to use CSOM to operate on your desired O365 site.


As you can see from the image above the nuget package will install all of what you need. You do not have to worry about much. Easy, right :)?

Links to know: