An Introduction to PnP Program and Provisioning Framework

Posted 15 March 2016 12:00 AM by Luis Manez

For almost two years now, a group from the Microsoft Patterns and Practices division, led by Vesa Juvonen, started the Office 365 Dev PnP program with the aim of helping clients transition and adopt SharePoint Full Trust solutions, Add-ins model, and to establish guidelines and best practices for a successful transition. 

PnP program components

Office 365 Dev PnP was released in GitHub, and soon after it was split into several repositories. These are some of the core components:

• PnP Sites Core:

This is the core PnP component. It consists of a library with different classes and methods that will make our lives easier when working with the SharePoint client-side object model (CSOM). In addition, it includes the Provisioning framework that we will discuss later on.

• PnP Provisioning Schema:

This project has the XML Schema used by the Provisioning framework. This XML will reminds us of the previous XML used in the “old-style” SharePoint solutions. It consists of most of the components of a SharePoint solution, such as Fields, ContentTypes, Lists, Files, Pages, RegionalSettings, etc.

• PnP PowerShell:

Power-Shell Command enables more useful methods.

• PnP:

This was the source repository that later was split into several repositories, among those mentioned above. This repository currently contains several samples of PnP use and other best practices.

Interesting samples

The following list contains some of the most interesting examples that we can find in PnP, we advise to view all of the examples.

• Branding Apply Branding:

This shows best practices when applying branding and other publishing features.

• Core Create Content Types:

It allows to create Content Types using PnP Core.

• Core Embed JavaScript:

Good practice when injecting JavaScript and updating User Interface.

• Core MMSSync:

Syncronization of Metadata TermStore through multiple TermStores.

• Provisioning Cloud Async Webjob:

Creation of Site Collections from a WebJob in Azure.

• UserProfile Manipulation CSOM Console:

User Profiles update through Client Object Model (CSOM).

Extensions and useful methods with CSOM

Some of the classes and methods that extend CSOM:

• Client Context Extensions Execute Query Retry

Similar to the ExecuteQuery () method, but it manages possible connection errors and applies several retries (10 by default, with a delay of 500 ms).

• Field and Content Type Extensions: 

Class with several extensions to work with Fields and Content Types.

• List Extensions: 

Extensions to work with Lists (create Lists, Views, get lists, etc.).

• Taxonomy Extensions: 

Extensions to work with Managed Metadata Fields (create MMD fields, create Terms, create Groups, etc).

Provisioning Framework

This is probably the star of PnP. This framework is intended to replace the old model of deployment for SharePoint solutions based on WSP solutions, and making it based on a remote model, using CSOM, and an XML scheme for defining of Columns, Lists, Pages, etc. As mentioned above, the XML scheme is defined in the project PnP-Provisioning-Schema and these are the core nodes:

The definition of a Template consists of:

The complete definition of the scheme can be found in:

Note: Not all of the Scheme nodes are supported by the Provisioning framework. For example, the Sequence Node allows to define SiteCollections and Sites within it, so it will be logical to assume that the framework allows to create Site Collections and Sites, however, this is something that is not supported (yet) by the framework.

There is a complex but complete example of XML in:

And the following C# code will provide the XML in an existing site:

XMLFileSystemTemplateProvider provider = new XMLFileSystemTemplateProvider(@"c:\temp\pnpprovisioningdemo", ""); string templateName = "template.xml"; ctx.Web.ApplyProvisioningTemplate(template);

A great benefit is that the framework also allows to create XML from an existing site (not everything is exported, for example, all the existing pages are not exported). For exporting a site and save the XML generated, we can use the following code:

XMLFileSystemTemplateProvider provider = new XMLFileSystemTemplateProvider(@"c:\temp\pnpprovisioningdemo", ""); string templateName = "template.xml"; provider.SaveAs(template, templateName);

We can also export a site as a Template, or apply an XML template from PowerShell, with the commands:

• Apply SPO Provisioning Template

• Get-SPOProvisioningTemplate

Follow-up of the PnP program

Besides the GitHub projects, the PnP team continuously release very interesting information about the development for Office 365:

• Yammer Network: 

This is probably the best way of keeping up to date about PnP. In addition, you can submit any questions and comments and receive support from the PnP team themselves.

• PnP Channel in Channel 9: 

Videos with demos and examples of use of PnP

• PnP Blog:

• Monthly community call of PnP: 

Write this date down in your calendar. Every month the PnP team holds a meeting at which they inform one another about the program’s state and roadmap, as well as demonstrate examples, etc. It was a pleasure to be able to catch up with the PnP team and receive updates from Vesa himself.


Add your comment





intranet Modern SharePoint teamwork employee engagement digital workspace SharePoint JavaScript Windows Azure Digital Transformation staff satisfaction productivity Microsoft Teams Office 365 Yammer cms content management system agile GDPR Microsoft Graph collaboration Microsoft sharepoint 2016 upgrade migration SharePoint Online 2016 Tech Trends Digital Disruption Context marketing marketing SharePoint 2010 SharePoint 2013 TFS Git security kentico Analytics jquery QA Quality Assurance testing content management websites Sitecore sitecore marketplace sitecore module cloud Microsoft Cloud Storage digital strategy technical consulting sitecore modules Experience database Sitecore 7 Sitecore 8 support account management customer experience Data Storage cms integration front end front end development prototype Cloud Storage StorSimple Front-end Development Layout SharePoint 2013 colour palette UI design website design log viewer sitecore cms website Azure big data business-critical sharepoint accessibility android apple chrome clear people clearpeople debug emulator ios mobile testing opera resize adobe desktop flash ie10 internet explorer 10 metro windows 8 bcsp Advanced System Reporter reporting framework ControlMode form control master page placeholder publishing console SharePoint 2007 SharePoint error search search results search values software testing testing scenario audit content information architecture retention schedules PowerShell QuickLaunch scripts SharePoint server 2010 business solutions metalogix replication replicator storagepoint stena technet UK Technet picture library slideshow web part RTM released to manufacturing caml caml query MOSS 2007 query infopath