Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue...

26

Transcript of Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue...

Page 1: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site
Page 2: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Todd Klindt

• 14 Year SharePoint MVP

• Writer, speaker, podcaster, consultant at Sympraxis Consulting, SysKit Chief Evangelist

[email protected]

@toddklindt

www.toddklindt.com

www.toddklindt.com/SPSNashville

Page 3: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Session Overview

Page 4: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site
Page 5: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

The Bad and the Ugly

• Only worked for Classic Team sites – “cheating” on Publishing sites often

broke

• So flaky they removed it from SharePoint Online

• No way to update sites once they are created

• Brittle – content sometimes breaks (error when clicking on a list for

example)

• Difficult to debug; generally arcane

The Good

• Easy peasy – make a sample of what you want, save as a template, then

use the template to create new site(s)

Page 6: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

It takes work to be this beautiful!

Page 7: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

See: Idempotent Site Scripts for SharePoint

Page 8: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Using Site Scripts to Deploy Content Types

See: SharePoint site design and site script overview and Site design JSON schema: Define a new content type

Page 9: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Site designs: modern templating model

A new script model to apply custom “actions” to a site after creation.

This approach is inspired by the “remote provisioning” pattern we’ve espoused through PnP

Page 10: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

• Updating existing sites with common site elements

• Configuring sites associated to a hub

Site Instances

Site Instances

Site Instances

Site Instances

Page 11: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Available Site Script Actions

JSON Schema: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-json-schema

Site Settings

• addPrincipalToSPGroup

• addNavLink

• removeNavLink

• applyTheme

• setSiteLogo

• setSiteBranding

• setRegionalSettings

• setSiteExternalSharingCapability

• triggerFlow

• joinHubSite

• activateSPFeature

SharePoint Components Apps & Solutions

• createSPList

• addSPField

• deleteSPField

• addSPFieldXml

• createSiteColumn

• createSiteColumnXml

• addSiteColumn

• addContentType

• createContentType

• removeContentType

• addSPView

• removeSPView

• setSPFieldCustomFormatter

• installSolution

• SPFx Extension support• associateExtension

• associateListViewCommandSet

• associateFieldCustomizer

Page 12: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

"$schema": "schema.json",actions: [...{

"verb": "createSPList","listName": "Contoso Project Tracker","templateType": 100,"subactions": [

{"verb": "SetDescription","description": "Custom list to illustrate

SharePoint site scripting capabilities"},{

"verb": "addContentType","name": "Contoso Projects"

},{

"verb": "addSPFieldXml","schemaXml": "<Field Type=\"Choice\"

DisplayName=\"Project Status\" Required=\"FALSE\" Format=\"Dropdown\" StaticName=\"ProjectStatus\" Name=\"ProjectStatus\"><Default>In progress</Default><CHOICES><CHOICE>In progress</CHOICE><CHOICE>In review</CHOICE><CHOICE>Has issues</CHOICE><CHOICE>Done</CHOICE></CHOICES></Field>"

},{

"verb": "addSPView","name": "Contoso Projects by Status","viewFields":

...

Site Script: JSON file of

actions to be applied to the

site post-creation

Actions can be concatenated in

single file or multiple files can be

used (and reused)

Add-SPOSiteDesign-Title <string>-WebTemplate <string>-SiteScripts <SPOSiteScriptPipeBind[]>[-Description <string>][-PreviewImageUrl <string>][-PreviewImageAltText <string>][-IsDefault]

Site Design attributes

designate display

characteristics and target

template

LIMITS• 100 site scripts and site designs

per tenant

• 30 actions/design if applied sync

(Invoke-SPOSiteDesign)

300 actions if applied async

(UI or Add-SPOSiteDesignTask)

• 30K characters/design

Page 13: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site
Page 14: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Get-SPOSiteScriptFromWeb –WebUrl $siteUrl-IncludeTheming –IncludeBranding-IncludeSiteExternalSharingCapability–IncludeRegionalSettings–IncludeLists $relativeListUrls

Page 15: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Tips and Tricks – Github Samples

Page 16: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Tips and Tricks – Create a Theme per Site Design

Page 17: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site
Page 18: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Add-SPOSiteScript -Title $siteScriptTitle –Content $siteScriptJson

Add-SPOSiteDesign -SiteScripts [$siteScript.Id]-Title $siteDesignTitle -WebTemplate $webTemplate-Description $siteDesignDescription-PreviewImageUrl $previewImageUrl-DesignPackageId $designPackageId

Grant-SPOSiteDesignRights -Identity $siteDesign.Id-Principals ("[email protected]")-Rights View

Set-SPOHubSite $hubSiteUrl -SiteDesignId $siteDesign.Id

Invoke-SPOSiteDesign -Identity $siteDesign.Id-WebUrl "https://contoso.sharepoint.com/sites/projectawesome"

Add-SPOSiteDesignTask -SiteDesignId $siteDesign.Id-WebUrl "https://contoso.sharepoint.com/sites/projectawesome"

Site Design PowerShell

Page 19: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

var flowScript = {"$schema": "schema.json","actions": [{

"primary_verb": "Flow.Trigger","target": “<<http post url>>","name": “contoso hr additions","parameters": {

"department": "HR","cost center": "1023"

}}

],"bindata": {},"version": 1

};

Site Scripts with app integrationHow to integrate custom logic into out-of-box provisioning flow

SharePoint

Online

Storage

Queue

Azure Function

Microsoft Flow

Site URL is used as a parameter to connect to site

using remote APIs. Customizations applied using

remote provisioning techniques, for example with

PnP remote provisioning template model.

Script initiates previously configured flow, using

the newly created site URL as parameter. Flow

includes a step to pass site URL to Azure storage

queue for delegating processing to Azure side.

1 2

3

4

triggerFlow script action

• Site URL

• Site Description

• Created By

• Creator Email

• UTC Creation Time

Page 20: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Site Designs for Existing Sites!

PowerShell or REST can be used to apply a published design to a site.

Page 21: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site
Page 22: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Notes

Page 23: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

http://bit.ly/UltimateGuide2SiteDesigns

http://bit.ly/SiteDesignOverview

http://bit.ly/SiteDesignSchema

http://bit.ly/SwoopingSiteDesigns

http://bit.ly/SwoopingSampleCode

http://bit.ly/SiteDesignAttachHubs

http://bit.ly/OfficeThemeGen

Page 24: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site
Page 25: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

[email protected]

@toddklindt

www.toddklindt.com

www.toddklindt.com/SPSNashville

Page 26: Creating Modern Site Templates Using Site Designs · 2020-05-08 · SharePoint Online Storage Queue Azure Function Microsoft Flow Site URL is used as a parameter to connect to site

Session Feedbackbit.ly/O365N-Todd

• Anonymous

• Results go to Speaker

• Greatly Appreciated