Related to this announcement, another item of this May release, is the changes at nuget package level, where we now have 3 packages oriented to each one of the different environments, including a specific version for the new SharePoint 2016:
- SharePoint PnP Core library for SharePoint Online
- Install-Package SharePointPnPCoreOnline
- SharePoint PnP Core library for SharePoint 2013
- Install-Package SharePointPnPCore2013
- SharePoint PnP Core library for SharePoint 2016
- Install-Package SharePointPnPCore2016
Currently the previous packages are still available, which have been also updated with the changes in May. However, note that they are already marked as [Deprecated], therefore they will be removed soon.
PnP program componentsLastly, before talking about the Provisioning Framework architecture, let’s remember some of the most renowned PnP components, in this case using a graph, as you can see in the following image:
Provisioning Framework ArchitectureWe are going to analyse in detail how the Provisioning Framework works and which is its architecture. In this case we are going to talk about the operation of importing a defined template in an XML file, to a SharePoint site. However, at architecture level, the operation of exporting a SharePoint site as XML template is very similar, but doing it in the opposite way. The cycle to apply an XML template to a SharePoint site works in 2 main steps. First, the content of the XML file is loaded to a business object “ProvisioningTemplate”, aftwerwards, this business object is run by the framework, doing the operations required in SharePoint.
The first step will be the following piece of code:
- Everything begins with the call to the method GetTemplate of a class that inherits from TemplateProviderBase.
- The Framework has support for defined templates both in XML and insi bi JSON, although the format is more extended in XML, and in fact I do not know anyone that uses JSON. Depending on the JSON/XML format, the class inherits from JsonTemplateProvider or XmlTemplateProvider. Besides, the Framework permits different storage for the file of the template, being able to store the file in the FileSystem, in a Blog Storage of Azure, or even in a SharePoint document library.
- The specific class TemplateProvider, will have property class base FileConnectorBase, with 3 specific implementations, that will connect to the storage system used: FileSystem, Azure Storage, SharePoint.
- The result of the connector FileConnectorBase will be a Stream represented by the content of the template XML/JSON.
- That Steam, goes through a class that implements the interface ITemplateFormatter, which converts the Stream to a business object ProvisioningTemplate. There are two implementations of this ITemplateFormatter, depending on if we are working with XML or JSON: XMLPnPSchemaFormatter and JsonPnPSchemaFormatter.
- Finally, when the Formatter finishes its tasks, we get a ProvisioningTemplate object, which contains properties of another business objects, representing entirely the template: Fields, ContentTypes, Files, Lists, etc.
And the following image describes the process applied:
- We start from the Provisioning Template loaded in the previous step.
- The extension of the object Web: ApplyProvisioningTemplate is invoked.
- The TokenParser class, translates the tokens used in the Template. There is a system of “Tokenizing”, that makes possible to use tokens in the XML and JSON, that are resolved in this moment with values depending on the context (for example, ~sitecollectionurl). You can see all the tokens available in the folder: OfficeDevPnP.Core\Framework\Provisioning\ObjectHandlers\TokenDefinitions.
- All the ObjectHandler are executed following a specific sequence. Each ObjectHandler is responsible for provisioning a part of the template to SharePoint. For example, the ObjectField will create Site Columns of the template in SharePoint.
- At this point, the Framework will call all our own Extensibility Handlers that we previously defined in the template. At this moment is when we can “inject” our own provisioning actions. For example, it can be very interesting to send an email when a template is applied, or make an integration with an external system, or any other action in SharePoint that is not supported by the Framework. With the execution of all the ObjectHandler, including our own ones, the provisioning process finishes.
Following PnP ProgramRemember the following ways of being up to date with the PnP program:
Presentation videos and examples of PnP use.
Write down this date in your calendar. Every month the PnP team holds a meeting at which they inform about the program’s state, the roadmap, they also show examples, etc. It is a real pleasure to be able to meet with the PnP team and receive updates from Vesa himself.