Partager via


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:

[View:https://www.youtube.com/watch?v=dnQj5EHTUm4]

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:

App Deployment

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.

Final Thoughts

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.

Comments

  • Anonymous
    March 04, 2013
    Good information, thanks for documenting this. Bummer that the forced deploys don't fire some sort of event.

  • Anonymous
    April 25, 2013
    Do you know if there is any way to make "App Stapling" or "Feature Stapling" to deploy/set a masterpage to My Sites?

  • Anonymous
    May 06, 2013
    Bruno - I've been able to achieve this, but it is buggy for the following reasons:

  • app installed events (which would be used for applying the masterpage to the site) only fires for the app catalog...not the individual sites
  • the masterpage needs to live within the site collection to be accepted and this is hard to do for new site collections
  • the app web isn't the best location for the masterpage because of potential authentication hops, but the only clean option you really have control of from your app. I think owning the provisioning process is a much better approach as is outlined in the following post: blogs.msdn.com/.../self-service-site-provisioning-using-apps-for-sharepoint-2013.aspx
  • Anonymous
    June 14, 2013
    Thanks.  Can you write a blog on how you developed app to brand RootWeb and handled remote events?  I look forward implementing a branding solution (App) for Office 365 sharePoint 2013 online via Apps.

  • Anonymous
    June 22, 2013
    The comment has been removed

  • Anonymous
    September 18, 2013
    Great post!  And thank you for including the details on the setup on-premise as well.

  • Anonymous
    October 09, 2013
    How do we do this via powershell for OnPrem deployments?

  • Anonymous
    November 21, 2013
    While debugging it is working fine,but When I try to deploy the SharePoint auto hosted app I am getting the error - Correlation Id: 4e2aa7aa-00be-4a4f-83bb-362a567c0e21 ErrorDetail: The remote hosting service is not configured. ErrorType: Configuration ErrorTypeName: Configuration ExceptionMessage: Microsoft.Office.SecureStoreService.Server.SecureStoreServiceTargetApplicationNotFoundException: Target application not found (application id: RemoteAppManagementInfo).

  • Anonymous
    December 02, 2013
    Thanks for tthis great guide :) In my experience the logged in user account need to be a "Site Collection Administrator" of the App Catalog Site Collection. If not, then you cannot se the "Deployment" link.

  • Anonymous
    December 03, 2013
    Thanks for the guide. But I have  one question: My app has custom actions. During deploying they are lost (not shown in the ribbon). Is there any way to publish custom actions??

  • Anonymous
    December 29, 2013
    Is there a way to use an app part within the target site of the shared app. I can only view the app part within my app when I install the app on the target site instead of the app catalog site. Thanks in advance

  • Anonymous
    January 11, 2014
    The comment has been removed

  • Anonymous
    February 14, 2014
    The comment has been removed

  • Anonymous
    March 21, 2014
    I am excited to see drag n drop skips over the whole deployment process that was time consuming in previous versions. I have a question: if you are deploying an App which will inject code into the Master Pages for individual Sites, how would (or if) you make sure that the injected code was removed when the App is?

  • Anonymous
    April 28, 2014
    HI Very Good Article which help me to develop app in sharepoint 2013. But i am having one more issue after configuring and deploying app to site . When i click to open app in browser ,it is asking credentials,but even though i am providing admin credentials,it is not accepting. Because of this i am not able to open app that i have developed. Kindly can any body share there knowledge how to resolve this issue

  • Anonymous
    April 30, 2014
    Can any body share solution for resolving the app's error in sharepoint 2013. In previous blog,i mentioned Issue that i am facing while developing and aceesing app in sharepoint 2013.

  • Anonymous
    June 23, 2014
    I have followed the steps as mentioned in the blog and also got the app installed on another site collection but in another site collection i never get the  about option for the app

  • Anonymous
    September 19, 2014
    Hi , I am having app in site . But when i click on that Thirdparty app. I am getting This webpage not available. Any idea. Thank you, Sowjanya.

  • Anonymous
    October 15, 2014
    The link on the chrome control in a Hosted app points to the app catalog not the original web the user came from.

  • Anonymous
    March 11, 2015
    Great post! How is this not more well known?

  • Anonymous
    April 09, 2015
    Thanks so much! Your instructions are very clear and helpful. I've been wondering how to do this for months and thrilled to find out how finally! <a href="staygreenacademy.com/.../">sharepoint tutorials</a>

  • Anonymous
    July 23, 2015
    Great post!   I'm able deploy my branding app without changes because it uses the "SPHostUrl" query string parameter to upload the modifying JavaScript to the correct web.  I'll add my own querystring parameters to automate and customize the appweb to hostweb upload action.  (See the Office Dev Center Patterns and Practices sample, Core.EmbedJavaScriptJSOM. github.com/.../PnP) I can't find any way to automate the Deployment from the App Catalog.  Is there a PowerShell or CSOM way of doing this?

  • Anonymous
    November 12, 2015
    Scenario: I have 10 site collections. An app for SharePoint is installed on one of the site collections. The same app needs to be called from all other site collections as a link. Is that possible to do?  Is there a way that I can get the URL of the site collection when it is invoked from other site collections?