“I’d love to use Solutions for Power Automate flows, but the environment variables keep changing with each import!”
When you’re building a new flow, it’s a good idea to start from a Solution. Create a solution and add the flow as part of this newly created solution. This way you’ll get a few benefits – you can use connection references instead of fixed connections, and environment variables for the flow configuration. Such flow is then much easier to manage as all you have to change are these references/variables. It can be also transferred between different environments with minimal friction, no need to touch the flow. You just update a few variables and the flow will work as e.g. the approval process template.
There might be a few small issues with the environment variables during the transfer though.
Don’t put environment variables into managed solutions
Update: you can actually update even managed environment variables through the “Default Solution”.
If you’re using managed solutions on the environment, don’t put the environment variables as part of that solution. By design, managed solutions can’t be changed (even though that’s not really true for Power Apps and flows), meaning you can’t change even the environment variables. Once it’s in a managed solution and you make a mistake, you’re done. You won’t be able to change it.
That’s why it’s better to keep the environment variables in a separate, unmanaged solution. You’ll get two benefits from that – you can change the environment variables, that’s the main one. The second is that you don’t have to transfer the environment variables with every solution import. The variables won’t change as often as the app or the flow might.
Remove the variables from unmanaged solutions once created
Similarly to the managed solutions, you don’t really want to keep the environment variables in the unmanaged solution all the time. While in managed solutions it’s the unchangeability that’s causing problems, in unmanaged solutions it’s the opposite – they sometimes change the values during the import. Instead of keeping the value defined on the environment, they’ll replace it with the original value, making the import more complicated as you might need to check / update the variables again.
To avoid this I keep also environment variables in unmanaged solutions separated:
- When you create the initial solution, include also the environment variables.
- For the first export/import to the other environment keep the solution as it is with the environment variables.
- Once imported for the first time, remove the environment variables from the solution. They already exist on the new environment, no need to import them again. IMPORTANT: Make sure you remove them only from the Solution, not from the whole environment!
- Create one extra solution on the environment and add all the environment variables in this solution. You still want to have the possibility of updating the variables some day in the future = they must be in some solution. It can be just a single solution for the whole environment where you aggregate all the environment variables.
- If you want to import the whole solution to a different environment, start from step 1 again.
The idea is the same a with the managed solutions – you don’t need to import environment variables over and over again. Once it’s enough. The first import will create them and they’ll stay on the environment, no need for keeping them in the solution all the time.
Summary
Dealing with environment variables can be sometimes confusing which is the reason why many builders don’t even use solutions for their Power Automate flows. But they’re nothing more than variables – you create them on the environment, configure them, and you’re done, nothing else is needed from your side. It’s not necessary to keep them in the solution that you export/import multiple times as they don’t change that often, maybe even not at all. Import them once, maybe even in a separate solution, and use them forever.