Power Platform: Managing Environment Variables in 'Managed Solutions'
What
Environment Variables are a great way to manage your solutions as they pass through DEV/TEST/PROD environments. They save having to manually update flows/apps during each change and test iteration.
However there is a gotcha to understand when you're planning your next migration or app update.
Why
The two issues I faced using Environment Variables were due to the 'Current Value'.
Issue #1: If you don't want the value you used in DEV to push through to TEST/PROD, you need to remove the 'Current Value' from your solution BEFORE exporting it.
If this is not done, and you're migrating as a managed solution, the 'Current Value' will flow through to your TEST environment, and cannot be changed because the solution is locked down.
Issue #2: If you're like me and you realised this AFTER you'd already imported into another environment, then selecting the 'Remove from Solution' option does not solve your problem, because the destination environment has now already stored the DEV 'Current Value'...
How
We're gonna solve issue #2 first.
- Go to TEST environment (or wherever you imported solution)
- Delete the managed solution - This will delete ALL the objects that are managed within the solution, including the environment variable
Now solve both Issue #1 & Issue #2
- Go to DEV solution, and remove Current Value 'from solution'.
- Publish and Export Solution
- Go to TEST environment, re-import. You should now be asked to populate the environment variable during import.
'Delete from this environment' forces you to add again to both DEV and TEST. So don't do this unless you really need to.
Other Tips
You can now add your data sources as environment variables, and automate the process for any data sources added to Canvas Apps: Automatically Create Data Source Environment Variables | MS Learn
- Unfortunately, this doesn't work perfectly, as you still have to manually edit the app in the destination environment for the Customisations.xml file to get the correct data source information.
- Crap workaround To resolve the Customizations.xml issue:
- You need to use Pipelines and provide a customised Deployment Settings file
- Follow the CLI steps here to create a Deployment settings file: https://learn.microsoft.com/en-us/power-platform/developer/cli/reference/solution#pac-solution-create-settings
- Follow the steps here to update the Deployment Settings file with correct data source references: https://learn.microsoft.com/en-us/power-platform/alm/conn-ref-env-variables-build-tools
Comments
Post a Comment