PnP program componentsOffice 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.
Power-Shell Command enables more useful methods.
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.
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.
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.
Extensions to work with Lists (create Lists, Views, get lists, etc.).
Extensions to work with Managed Metadata Fields (create MMD fields, create Terms, create Groups, etc).
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
Follow-up of the PnP program
Besides the GitHub projects, the PnP team continuously release very interesting information about the development for Office 365:
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
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.