Moving a Canvas app into a solution and keeping the associated URL and ID in different environments

If for any reason you have built a Canvas app outside of a Solution, and published it to multiple environments using the export/import functionality of Power Apps, if later you decide to add it to a solution (best practice) and redeploy the app to those environments using solution export/import, you will be duplicating the canvas app and the canvas app present in the solution will have a different ID and by consequence a different access URL, which can be a pain if there are a lot of users already using the app and you want them to use the new version (from the solution).

However, we can use a special Power Apps PowerShell cmdlet before importing the solution into those environments and avoid this hassle:

Set-AdminPowerAppDesiredLogicalName

How to use the cmdlet and make the solution import work correctly keeping the same app ID

The following steps assume that app already is imported in multiple environments such as dev/UAT/Production and not added to any solution.

In the development environment, add the app to a solution. After adding it to a solution, the system will give it a name as below:

In my case the Name is: tmichel_apptobemoved_411e0

Save the “name” of the canvas app so you can use it with the PowerShell cmdlet. You can now develop any changes you want to the Canvas app, then publish it and Export the solution.

Before importing the Solution

In the UAT, production and other environments run the Set-AdminPowerAppDesiredLogicalName PowerShell cmdlet and set the DesiredLogicalName for the app to the name you noted earlier (in the sample it was tmichel_apptobemoved_411e0).

The cmdlet needs 3 Parameters:

  • AppName : this is the App ID which you can find in the app details page
  • EnvironmentName: ID of the target environment (GUID) – you find it easily from make.powerapps.com when you switch to that environment in the current URL, for example: https://make.powerapps.com/environments/6e314590-9414-4f28-81f7-b99eb8c67d8f/home
  • DesiredLogicalName: the name you noted when adding the app to a solution in the development environment

This step is required only once, before importing this solution for the first time.

By running this cmdlet, when you import the solution, the imported canvas app will match the existing canvas app internal name, overwrite it and by doing so it will be kept as solution aware while maintaining its ID and URL.

Import the solution

Import the solution exported previously, containing the updated canvas app. After doing this, the Canvas app will be now part of a solution and will keep its previous ID and URL.

Conclusion

By running the Set-AdminPowerAppDesiredLogicalName cmdlet and updating the desired logical name for a Canvas app, when it is reimported as part of a solution it will keep its previous ID and URL.

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *