6 min readRishi

Managing Environment Variables Across Dev, Test, and Prod in Power Platform

In this series: Power Automate gotchas

Managing Environment Variables Across Dev, Test, and Prod in Power Platform

Hardcoding a SharePoint site URL, a Dataverse environment id, or an API host in a Power Automate expression guarantees the flow will break on the first import to test. The value is correct in the environment where you built it and wrong everywhere else. Environment variables and connection references are the supported way to keep the flow definition the same and the configuration different.

This is the ALM shape I use in 2026. It is not new — environment variables have been in solutions for years — but the failure modes are still the same: current values travelling with the solution, secrets stored as text, and connections baked into the flow instead of referenced.

Environment variables live in the solution

Create them inside the solution you will export, not as unmanaged leftovers in the default solution.

  1. Open the solution in make.powerapps.com
  2. New > More > Environment variable
  3. Set Display name, Schema name, Type (text, number, JSON, data source, secret), and a Default value

Use the default value as the safe fallback (often the dev URL), not as production. Production is a current value you set on import or in the pipeline stage.

Default versus current

This is the distinction that burns people:

  • Default value is part of the solution component. It travels on every export.
  • Current value is an environment-specific override. If you export with current values, you will overwrite test with whatever was current in the source.

When you export for a pipeline, export without current values unless you intend to seed the next environment. In the Maker portal that is the "include current values" toggle on export. With PAC:

pac solution export --path out.zip --name YourSolution --managed false

Then use a deployment settings file (or pipeline stage configuration) to supply current values per target. Do not hand-edit the imported flow.

Referencing in a flow

After the variable is in the same solution as the flow, it appears in dynamic content. In an expression the historical form is:

@parameters('new_SharePointSiteUrl')

The schema name is what you typed when you created the variable, with the publisher prefix. If dynamic content does not show it, the variable is not in the solution, or the flow was created outside the solution and never added.

JSON-type variables are useful for a small bundle of related settings (a host plus a path prefix). Parse them once in a Compose and read properties from that output. Do not nest ten text variables for what is one config object.

Secret type

For API keys, use type Secret and store the value in Azure Key Vault. The environment variable holds a reference, not the secret itself.

  1. Create a Key Vault and a secret
  2. Grant the Dataverse / Power Platform enterprise application (or the identity documented for your tenant) get access to that secret
  3. Create the environment variable as Secret and point it at the vault reference

The flow reads the secret at runtime. It should not appear in the flow definition or in run history as plaintext. If you can see the key in a Compose output, you used a text variable. That is a finding, not a convenience.

Do not put connection strings for SQL or Dataverse into environment variables when a connector and a connection reference already exist. The connection reference is the credential. The environment variable is the which site / which list / which host part.

Connection references

Connections (Dataverse, SharePoint, Outlook, SQL) are environment-specific by nature. A flow that still has a raw connection instead of a connection reference will import with errors or, worse, keep pointing at the source environment.

  1. Add a connection reference to the solution
  2. Edit every action so it uses that reference
  3. On import, map the reference to a connection that exists in the target environment

If an action still shows a user-owned connection after you think you cleaned up, open the action, change the connection to the reference, and save. One leftover action is enough to make a managed import look like "the whole flow is broken."

Connection references and environment variables solve different problems. The reference is who is calling. The variable is what they are calling. You need both when the same connector hits different sites per environment.

Pipelines and deployment settings

Power Platform pipelines (GA since 2023, preinstalled on the pipelines host environment) can set current values and connection mappings per stage. That is the path I want for anything that leaves a personal environment.

A typical stage file (conceptually) is: source = Dev, Test gets test URLs and test connections, Production gets prod URLs and prod connections. The flow XML does not change. If you find yourself maintaining three copies of the same flow, you have already lost.

pac solution export plus a deployment settings JSON is the CLI equivalent when you are not using the pipelines UI. The settings file lists environment variable values and connection reference mappings. Keep it in source control next to the solution, with prod values coming from the pipeline secret store, not from a committed file.

What still goes wrong

  • Compose used as a variable. A Compose with a hardcoded URL is not configuration. It will not prompt on import.
  • Default value is production. Then a fresh install of the solution in a sandbox talks to prod until someone notices.
  • Current values exported from prod back into source. The next unmanaged export from a hotfix environment writes prod URLs into the repo.
  • Secret stored as text. Works until the solution is shared or the run history is exported.
  • Connection not converted to a reference. Import succeeds, first run talks to the wrong tenant or fails on consent.

Key takeaway

Environment variables for configuration, connection references for connectors, pipelines (or PAC deployment settings) for the swap. Default values are fallbacks. Current values are per environment and should not ride along on every export. If a URL is still in an expression, the next import is already broken.

Keep reading

Newsletter

New posts, straight to your inbox

One email when a new post goes up. Double opt-in, unsubscribe anytime. Not a daily digest.

Comments

  • No comments yet. Be the first.