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.

When a single sentence in an MS Learn article can cause so much pain...


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'...

Oh sweet, another one liner that could have been solved with a better UI design in Solutions...

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 

Comments

Popular posts from this blog

SharePoint - Field type [FieldName] is not installed properly. Go to the list settings page to delete this field.

Office 365 Groups - Quickly find the GUID of a O365 Group

Export Group Membership From Active Directory Using Power Query