Sunday, March 4, 2018

Provisioning sites using SharePoint Site Design and Site Script

The newest capability for creating SharePoint sites based on a template was rolled out in Office 365. Site designs and site scripts automatically apply custom configuration when new SharePoint sites are created. It’s completely integrated in the SharePoint UI and offers an alternative to the PnP provisioning engine. In this blogpost, I will demonstrate to you how to work with this new capability in different scenarios.

Important: You may need to update your SharePoint Online Management Shell to the version 16.0.7414.1200 or later, in order to use the demonstrated PowerShell commands below.


Topics:

  1. Understanding site scripts
  2. Create a site script and a site design
  3. Manage access to site design
  4. Create a SharePoint site from a site design
  5. Apply site design to an existing SharePoint site

1. Understanding site scripts


If you have been working with PnP to provision content to SharePoint sites, you’ll notice that site scripts have no similarity to the PnP schema, which is ok, since PnP is an open source project maintained by the community and not by Microsoft. Now Microsoft brought his own toy to the site provisioning’s playground. It supports triggering Flow, but in terms of provisioning it includes much fewer functions than PnP.

The site script’s schema is not difficult to understand since it is based on a JSON structure which works with a list of actions. Each action is specified by a verb value which must be written correctly since they are treated as case sensitive values. Below you see a list of supported actions:
  • applyTheme: Applies a custom theme
  • setSiteExternalSharingCapability: Manages guest access
  • createSPList: Creates a new list
  • addNavLink: Adds a navigation link
  • triggerFlow: Triggers a Microsoft flow
  • setSiteLogo: Sets a logo to a communication site (Not supported in team sites)
  • joinHubSite: Joins a hub site

Here is what a site script schema configured with all the actions above looks like:

Here you find recent information about site scripts’ supported actions.

Important: SharePoint Hub Sites are expected to be rolled out to Office 365 First Release tenants in the first half of 2018.

Update 25.03.2018: SharePoint Hub Sites are now rolling out to targeted release customers in Office 365.

2. Create a site script and a site design


This step demonstrates to you how to add the site script above to SharePoint online and to create a site design which uses that site script.

The property WebTemplate provides the set up for the following templates:
  • 64: Register this site design with the team site template (modern site)
  • 68: Register this site design with the communicate site template

The property SiteScript is an array of site scripts which run the entered scripts in the listed order. Here is what the added site design looks like in SharePoint:


3. Manage access to site design


Image this scenario: only site collection administrators can create sites in your organization. Scoping was added to site designs to handle this business requirement exactly. You can configure site designs to only appear for specific groups or people in your tenant.

Site designs are by default available to everyone in your organization, but there are two different kinds of scopes you can set up:
  • User:                          Email address – e.g.: jarbas.horst@example.onmicrosoft.com
  • Security Group:       Group’s display name or principal – e.g.: Administrators or c:0t.c|tenant|5ec63687-daf1-4d36-8689-213cdf2f3767

The example below shows how to specify the scope by a security group:

The property Rights can only be set up to View which restricts the site design’s usage to the defined users/groups.

4. Create a SharePoint site from a site design


You can start creating your SharePoint sites based on the site design you’ve just created from the SharePoint UI. Below you'll find the steps needed:
  1. Navigate to your SharePoint site’s home page (https://example.sharepoint.com/_layouts/15/sharepoint.aspx)
  2. Click Create site
  3. Select Team site since we created a site design for team sites
  4. Choose the design we’ve just created (Project)
  5. Enter a site name, click Next than Finish
  6. Click View updated site after the script applied

5. Apply site design to an existing SharePoint site


Running a site design on an existing SharePoint site processes delta changes. This means that either changes apply to the site without corrupting existing data or that a full provision occurs. Of course, the full provision will occur if the provisioned data hasn't been available in the site before.

This can only be done programmatically since there is no UI support yet. The PowerShell script below demonstrates to you how to run the site design on an existing site.


Summary:


I see two great advantages to SharePoint administrators in working with site design:
  1. Direct integration in the SharePoint UI: Anyone can create custom SharePoint sites without the need to run PowerShell scripts, such as PnP.
  2. Capability of triggering Flow: "Everything" is possible J For instance, you can continue using your PnP templates from Microsoft Flow.
I can't wait to see what Microsoft has planned for site designs.

Links:

No comments:

Post a Comment