No, it’s not just a halfway-decent Star Wars movie—it’s a real use case in Office 365. Learn how to easily “clone” SharePoint sites and create flexible, reusable site templates in Office 365, using tools provided by Microsoft’s official Patterns and Practices community.
This deck covers simple template creation and application with PowerShell, plus more advanced scenarios like provider-hosted site collection provisioning using the Add-In Model.
Injustice - Developers Among Us (SciFiDevCon 2024)
O365: Attack of the Clones
1. Office 365:
Attack of the Clones!
Building Site Templates with the
Office 365 PnP Framework
2. Agenda
• Introduction
• The case for site templates
• Old way
• New way
• Introducing Office Dev PnP
• Demos (3)
• Getting started - PnP resources
• Questions
3. Chris Johnson
@cjohnsonO365
• Microsoft MVP – Office Development
• Director, PSC Group (Schaumburg, IL)
• 7+ years developing for SharePoint
• Document Management
• Branding
• Managed Metadata
• Provisioning and Governance
• Office 365
• Nintex Forms & Workflow
• Current focus: app modernization & cloud readiness
4. 1. SharePoint Developer Office
365 Developer
2. This is an amazing time to be an
Office 365 developer!
5. Hey, listen!
• Some images used on these slides have been borrowed from the Office
Dev PnP site. These– especially the artsy ones– are not my creation!
• A lot of the code you see during this presentation was written by me, but
it’s built on frameworks and sample code from the PnP community
• I will tweet out links after the presentation so you can:
• Go to the Office Dev PnP site
• Connect to the GitHub repo
• Download code from demos
• View this slide deck, etc.
@cjohnsonO365
6. Raise your hand if:
• You’re an end user, power
user or BA
• You’re an administrator
• You’re a developer /
architect / consultant / etc.
• You use SharePoint 2013 on-
premise
• You use Office 365
• You use a hybrid farm
• You’ve ever tried to provision
custom sites in SharePoint
• You’ve heard of the OfficeDev
Patterns and Practices
community
• You’ve use a PnP framework,
solution or sample project
8. Community: Current SharePoint Initiatives
Application Modernization
“Get me to the cloud!”
• Re-write server-side LOB
applications to use “App
Model” CSOM
• Decrease dependencies
on feature.xml
• Eliminate custom master
pages
• Increase OOB feature
usage
Take advantage of NEW
Office 365 features
• Unified Experience
Unified Endpoint
• New APIs for Office
Graph, Delve, etc.
• Consistency across Add-
Ins: Office, SharePoint,
etc.
Build a better user
experience
• Modern web applications
over “SharePoint-y” UI
• New mobile experiences
• Office mobile apps
• PowerApps
• Next-generation
portals
• Lean on provider-hosted
apps
9. The case for site templates
WHY
• Easily reproduce common business
customizations
• Enforce governance
• Provide consistent user experience
WHAT
• Fields
• Content types
• Lists and libraries
• Groups
• Permissions
• Pages
• Web parts
• Navigation
• Look and feel
• Custom actions
10. The old way
• Site Settings Save as template
• Sometimes worked
• Import to Visual Studio (disaster)
• Site Definitions
• onet.xml (kinda hairy)
• Publishing? Good luck!
• Custom subclass of SPWebProvisioningProvider
• Create site, then apply changes (this is good!)
• Requires full-trust code deployed as solution in Central Administration
• Great on-prem solution, but very advanced
11. Limitations in Office 365
• No full-trust code No custom
SPWebProvisioningProvider
• “Save as template” still unreliable
• Use of sandbox solutions and Feature.xml
discouraged
Why are these
limitations in place?
• Ensure forwards
compatibility
• Provide flexibility
for:
• Developers
• Administrators
• Users
12. Client-side development in Office 365
BENEFITS
• Streamlined deployment
• Use the framework of your
choice
• Safe
LIMITATIONS
• Asynchronous
• More complicated
programming
• Less documentation
• API is less complete
13. Introducing: Office Dev PnP
• More than just a provisioning
framework
• Several core frameworks –
Provisioning is just one of them
• Also a thriving community
• Fills gaps in client-side development
paradigm
• Guidance & best practices for:
• Add-ins
• Branding
• Event receivers
• Timer jobs
• Workflow
• Managed Metadata
• Provisioning
• More
from the Office Dev PnP site
14. Introducing: Office Dev PnP
• Solutions
• Samples
• Frameworks
…that constitute best practices for administration
and development on Office 365
...ALL open source in GitHub!
…ALL documented!
...Frequently updated: monthly releases with
open conference call
16. Wish list: Cloud-ready provisioning solution
• Ability to provision:
• Look and feel
• Fields
• Content types
• Lists and libraries
• Groups
• Permissions
• Pages
• Web parts
• Client-side object model
• Scriptable OR deployable as an
app
• Declarative OR
compiled/managed code
• Documented
19. PnP Provisioning: Advanced Implementation
SOLUTION COMPONENTS
• Provider-hosted SharePoint Add-In
• ASP.NET MVC web site hosted in Azure
• AppInstalled and AppUninstalled event
receivers (Azure service bus) that create
artifacts on host web
• Timer Job (Azure Web Job) w/logging
• User-managed custom Site Templates based
on PnP Provisioning Schema
• Common library + PnP extensions
HOST WEB ARTIFACTS
• SharePoint Lists for site requests (on host
web to allow integration with other
applications, e.g. Nintex)
• SharePoint Library for templates (associate
with base template, e.g. Team Site-- allow
site requests to choose template)
• Custom ribbon actions to request and cancel
provisioning
• Ribbon control w/ScriptEnabled methods
• JavaScript ScriptLink custom action to
override "New Site" link on provisioned sites
• Branding assets
21. New SharePoint
Site Collection
ASP.NET MVC Provider-
Hosted App
C#
Service Bus
C#
PnP Core Framework
+ Helper Classes
C#
Azure Web Job
(Console App)
C#
App
Host Web
Library:
Site
Templates
List:
Requests
INSTALLED ON1
PROVIDES APP-ONLY SECURITY
TOKEN TO HOST WEB
2
APPINSTALLING EVENT CREATES
LIST, LIBRARY, CUSTOM ACTIONS
+ UPLOADS ASSETS ON HOST WEB
3
UPLOADS
TEMPLATE4
CREATES
REQUEST5RETRIEVES SITE
COLLECTION REQUESTS
FROM LIST
6
RETRIEVES USER-MANAGED
TEMPLATE FROM LIBRARY7
CREATES SITE COLLECTION
+ APPLIES TEMPLATE
+ APPLIES ADD’L CONFIGURATION
8
XML
</>
23. This is an amazing time to be an
Office 365 developer!
24. Where to find Office Dev PnP
Office Dev Center http://dev.office.com/patterns-and-practices
GitHub https://github.com/OfficeDev/PnP
Twitter @OfficeDevPnP
@ErwinVanHunen
@VesaJuvonen
@PaoloPia
from the Office Dev PnP site
@cjohnsonO365