PowerApps

The functionality in PowerApps allowing to export an application and then import it in a different environment or to migrate it this way to your customer’s tenant is known. However this works like a charm when talking about standalone apps. Is it possible to import a list form made in PowerApps as well? Yes! Maybe not very straightforward, but yes.

Exporting an app

First you need to export your existing PowerApp list form. This is done the same as for the standalone app. Simply open your app in the designer, then in “Save” menu click “See all versions”:

Navigating to the "Export package" functionality
Navigating to the “Export package” functionality

Then in the opened page click “Export package” link:

Exporting PowerApps app as a package
Exporting PowerApps app as a package

Then, depending on your scenario, set name of the package, mark whether the app should be imported as a new one, or to update existing one. For the purposes of this post I selected “Create as new”.

Adjusting exported app configuration

If you try to import the app right away, you face errors – app fails to import, showing e.g. the below errors:

Errors when trying to directly import PowerApps list form package
Errors when trying to directly import PowerApps list form package

And when you open the error’s details:

Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException
Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException

This is due to the fact, that inside the package file there are defined relationships and GUIDs to the lists and site from the source location.

To solve it, first you need to create all the required lists, preferably with the same titles and columns, as there were in the source environment.

Then open the exported app – this is a ZIP file, therefore even using Windows Explorer you should be able to get into its contents.

After opening the ZIP, navigate to the last folder you can find. It is the only folder in the “apps” subfolder, under the path:
Microsoft.PowerApps\apps\[numeric values]

Inside the folder look for the only JSON file. Open it using e.g. Visual Studio Code. The code inside basically defines the app configuration. What is important, is to make changes in the following sections.

In the connectionReferences section you will find all the connections defined and used by the application, e.g. Outlook, OneDrive and others and certainly, for this case – SharePoint. Now look for the dataSets section. It contains definitions of all lists that are being used by the application. Adjust their GUIDs to the values from you target environment:

            "connectionReferences": {
                "1dd34a9f-a232-48d7-b9b1-f3a149529511": {
                    "id": "49384936-6f18-4567-8283-411e553280d2",
                    "displayName": "SharePoint",
                    "iconUri": "https://connectoricons-prod.azureedge.net/sharepointonline/icon_1.0.1008.1183.png",
                    "dataSources": [
                        "LIST OF DATA SOURCES USED BY THE APP, e.g. SHAREPOINT LISTS’ TITLES"
                    ],
                    "dependencies": [],
                    "dependents": [],
                    "parameterHints": {},
                    "isOnPremiseConnection": false,
                    "bypassConsent": false,
                    "dataSets": {
                        "URL TO THE SITE": {
                            "dataSources": {
                                "LIST NAME": {
                                    "tableName": "LIST GUID"
                            }
                        }
                    },

Next scroll to embeddedApp section. It defines the location where the app should be deployed. Change siteId, listId and listUrl to values related to your target environment.

"embeddedApp": {
                "siteId": "SITE URL",
                "listId": "DESTINANTION LIST’S GUID",
                "listUrl": "DESTINATION LIST’S URL",
                "type": "SharepointFormApp",
                "screenWidth": 1185,
                "screenHeight": 790
            },

In the end save the file elsewhere and update the related file in the archive (app package). Once done, go to web.powerapps.com in your target environment.

Importing PowerApps package as a SharePoint list form

This process is also the same as when importing a package of a standalone app. Simply open the “Apps” page in PowerApps and then click the “Import package” link:

Importing PowerApps app package
Importing PowerApps app package

Then navigate to your saved ZIP file with the modified JSON file inside. After selecting it, importing mechanism asks whether to import app as new one, or to update. In my scenario there is no app to be updated, therefore I chose to import it as new. After couple of seconds your app is properly imported as a list’s form.

After doing that please remember to open your imported form in the designer, and check whether all data sources were properly re-linked and that all permissions are working fine. If you face any issues with accessing the lists, simply remove these data sources and add them again.

Remember publish your app at the end. Enjoy!