Export (0) Print
Expand All

App for SharePoint update process

apps for SharePoint

Learn about the process for updating apps for SharePoint.

Last modified: June 16, 2014

Applies to: apps for SharePoint | Office 365 | SharePoint Foundation 2013 | SharePoint Server 2013

You have to update an app for SharePoint if you add functionality, fix a bug, or make a security update. An update to an app is deployed in an app for SharePoint package in the same way that the first version of the app is deployed. The app for SharePoint update process ensures that the app's data is preserved if the update fails for any reason.

Important note Important

You cannot change the app type using the update system. For example, you cannot change an app from SharePoint-hosted to provider-hosted with an update. To make a change of type, you need to migrate from an old app to a new one. In particular, since the preview program for autohosted apps has been closed, you should be aware that cannot update an autohosted app to a provider-hosted app. You have to convert the app as explained in How to: Convert an autohosted app for SharePoint to a provider-hosted app.

For an update, you use the same product ID in the app manifest that you used for the original version. The version number in the app manifest should be greater than the version number of the original app or the most recent update.

Within 24 hours after you upload your update to an organization's app catalog, and within a week of uploading it to the Office Store, an indication that an update is available appears next to the app's listing on the Site Contents page of every website where it is installed. Users can click a link to update the app as shown in Figure 1. Available updates are also exposed in the tenant management UI.

Figure 1 App for SharePoint upgrade process

The UI steps for updating an app
Tip Tip
  • When you are developing an update, you don't want to wait 24 hours every time you upload a new version to your test SharePoint app catalog. See Update an app without waiting 24 hours for information about how to immediately update an app.

  • By default, SharePoint checks every 24 hours for updates to installed apps. A farm administrator can set this to another value by using the following SharePoint Management Shell command, where n is the number of hours between checks.

    Set-SPInternalAppStateUpdateInterval -AppStateSyncHours n

    If the value is set to 0, then the check is made every time the built-in timer job Internal App State Update executes, which by default is every hour. Farm administrators can use Central Admin to change the frequency of the timer job or run it immediately.

SharePoint 2013 will do the following when a user installs an update to an app for SharePoint. These events do not necessarily occur in exactly this order, and some of them may occur in parallel. Also, if update fails, there is a complete rollback.

  • SharePoint 2013 prompts the user to approve permissions requested by the app.

  • SharePoint 2013 makes the app unavailable to users temporarily.

  • If the app contains a SharePoint solution package (.wsp), and the contents of the solution package have changed in any way, SharePoint does the following:

    • Makes a backup of the app web. (But the actual data in SharePoint lists is backed up only if the update is making a change in the list's schema.)

    • Tests the update of the backup.

    • If the test succeeds, updates the original app web. Note that the new .wsp file in the app package is used to update the Features and other elements in the app web. (The update parts of the Feature schema have been expanded in SharePoint 2013.)

  • SharePoint 2013 executes the UpgradedEventEndpoint web service, if any is registered in the app manifest.

    Note Note

    If the app is provider-hosted, you provide the update logic for all the non-SharePoint components of the app. For the most part, you update these components separately from the update of the app for SharePoint itself, just as you installed these components separately from the installation of the app. But there may be some changes that should only happen when a user is updating the app for SharePoint. This logic can go in an UpgradedEventEndpoint web service or in "first run after update" logic of the app itself.

  • SharePoint 2013 makes the app and its components available again.

Note Note

If the schema of any list in the app web is being changed, then the list is backed up along with the rest of the app web. This can take some time if there is a lot of data in the list. If the update process cannot complete in 1 hour, it stops and the update is rolled back.

In some scenarios you may want to produce an entirely new app to replace an old one, rather than update the original one. The new app can have the same friendly name as the old, but it must be given a new product ID in the app manifest, and it will appear in the public Office Store and in the Add an App page of SharePoint websites as a distinct item from the original version.

Note Note

Items in an organization's app catalog are distinguished by the file name of the app package, not the product ID or the name of the app. If the new app has the same package file name as the old, it will replace the old one in the app catalog, and the old app will no longer appear on the Add an App page. If you enable versioning on the app package when you upload it to the catalog, the old version of the file (which is the old app) is still available in the item's history. You can download the old app package or revert to it, but there is no way to have both the old and new apps as separate items in the catalog or on the Add an App page, unless they have distinct file names.

In some cases, you might need to migrate data. For example, the new app might use a Microsoft Azure SQL Database that has a different schema from the old app. Or the new app might use a different data storage mechanism; for example, an external database instead of SharePoint lists. You must provide the code for data migration.

If your old data is somewhere that can be accessed by a remote event handler, you can implement migration logic in an InstalledEventEndpoint web service of the new app. Alternatively, if the new app has access to the old data, you can put the migration logic in code that runs the first time that a user starts the new app. If the old data cannot be accessed by either the remote handlers or the new app, you can create an update of the old app that adds a data export capability and a UI for the capability. Users would first update the old app, and then use it to export the data to a location where the new app can access it. You include the capability and UI to import data in the new app.

In principle, you can reuse an external data source, compute component, or other external component in the new app that was used in the old app. Consider, however, that when an app for SharePoint is uninstalled, the SharePoint 2013 infrastructure will uninstall everything that it installed. Accordingly, it is generally a good practice for an app for SharePoint to depend on only components that it installed or external components that were not installed by the SharePoint 2013 infrastructure.

Note Note

We recommend that if you implement an InstalledEventEndpoint or an UpgradedEventEndpoint that installs components, you should also implement an UninstallingEventEndpoint that uninstalls those same components. Doing so conforms to the design principles that apps should be self-contained and uninstall cleanly. However, data that would still be useful to users after the app is uninstalled should not be deleted. Websites created by an app, other than the app web, should usually be considered data.

If the old and new apps each contain an app web, consider that a new app web is created when your new app is installed. For this reason, you should not use the update-related XML markup in the SharePoint 2013 Feature schema. Such markup does not work because you are not updating existing SharePoint components; you are replacing an old app with a new one.

Show:
© 2014 Microsoft