I’ve been meaning to play with Environment Variables in Power Automate a bit more and spent some time with them today using them in conjunction with Pipelines.
Environment Variables are a great replacement for those configuration entities you used to create that lets you configure environment data as you deploy it and then let your code consume it (without you having to go change it after the fact).
Setting up the Environment Variable
In the demo solution I have, I created a pretty simple environment variable, added it to my solution and gave it a default value (for that specific environment).

I kept it to a string, but that is just scratching the surface as I can link it to an Azure Key Vault, JSON snippet or a completely different datasource (which is pretty cool if you have a configuration controller for managing all things in your deployment infrastructure).
I then updated my Power Automate flow to consume this variable in a simple flow that updates a contact when a new record is created.

Deploying the Solution
The final step was deploying the solution to another environment to see how it would be leveraged in my solution. Using PowerApps Pipelines, I created a pipeline for this solution and went to deploy it. As expected, upon deployment I was prompted to give the variable a value.

Upon doing this, my solution was deployed and when I went to validate my cloud flow I could see the new value being consumed by my flow.
Updating the Environment Variable?
I then wanted to go a step further and simply update the variable in the new environment but when I went to do this, I found I could not because the solution I deployed the component is a managed solution so I could not edit it.

At first, I was a bit perturbed because I wouldn’t be able to create an “overridden” variable in that environment but when I thought about it more it made sense;
- The deployment process is the opportunity to set your variables up. If you make a mistake, redeploy your solution and let Pipelines keep track of your version deployment history.
- The whole reason you deploy as Managed is to introduce some consistency in the work that you do. You don’t need someone coming along and changing what you do after the fact because they made a mistake elsewhere.
- Become better at planning.
I very much could have used Environment Variables more in the work I had recently done, but now I know to use them better in future work going forward. I definitely want to try doing some more complex data storage with them going forward.