SharePoint 2013 App Deployment through "App Stapling"
Feature Stapling is a popular development practice for adding functionality to a specific type of site in SharePoint. Although it has become the preferred approach over custom site definitions, it still requires the deployment of a farm solution. Unfortunately, SharePoint Online doesn’t support features stapling or custom site definitions. So how can an organization deploy capabilities to a group of existing sites or new sites that match specific criteria? The answer is app deployment through an app catalog…something I like to call “app stapling”. Here is a video that illustrates the concepts outlined in this blog post:
The App Catalog
The App Catalog is a special site collection aimed at storing, managing, and delivering Office/SharePoint apps to the enterprise. Administrators of an App Catalog can upload apps and make them available to site owners (they can also flip a kill switch to disable the apps). However, administrators can also use the catalog to push apps to specific site collections, managed paths, and site templates. To get started, you should provision an app catalog in your tenancy (on premise users will need to do additional steps outlined in Configure an environment for apps for SharePoint). This can be done from SharePoint Admin Center in Office 365 by clicking on the Apps link in the side navigation and then selecting App Catalog:
Once the App Catalog has been provisioned, it should look similar to this:
In order to "push" and app out to specific sites, we first need to upload it to the App Catalog. Navigate to the App Catalog and select the Apps for SharePoint link in the side navigation. You can simply drag/drop an .app file into this library to make it available to the organization:
Next, we need to install the app into the App Catalog (not to be confused with uploading to the App Catalog). This seems a little odd, but it is the only way to push it specific sites in the tenancy. You can install the app into the App Catalog just like you would from any other SharePoint site. Select Site Content > add an app > From Your Organization > and select the app to install:
Now that the app is installed into the App Catalog, we can manage the deployment to other sites. Select Site Content from the App Catalog and find the installed app. Selecting the ellipse should display a "Deployment" option does doesn't display in other sites:
This Manage App Deployment screen allows an administrator deploy/retract an app to/from specific site collections, managed paths, and site templates. Performing this "app staple" will work on all existing sites and any new sites that meet the criteria.
A few interesting notes about how this functions:
- Similar to deployment, an App Catalog administrator can retract apps from specific sites (or flip the kill switch to disable it from all sites)
- Because the app is pushed by an administrator, site owners will not be able to remove the app from a site that meets the deployment criteria. Not even a site collection administrator can remove the app.
- This centralized deployment also share the same centralized app resources (App Web and Remote Web). Essentially, the app is deployed, but not installed in the sites. All sites will leverage the App Web and Remote Web from the instance installed in the App Catalog. This significantly changes tenancy considerations for SharePoint-hosted and Autohosted apps, which typically get their own dedicate app resources.
- Because of centralized deployment, remote events such as “Handle App Installed”, “Handle App Uninstalled”, and “Handle App Upgrade” will only fire once (when the app is installed in the App Catalog). Because of this, I think it will be hard to leverage “App Stapling” for branding purposes. I’ve successful developed branding apps that deploy/set a masterpage from the App Web, but the remote events were a key part of that solution.
App deployment through the App Catalog provides a great deal of flexibility and governance for SharePoint deployments on-premise and in Office 365. I can see “App Stapling” being used for a number of scenarios where feature-stapling has been used in the past.