Citizen Developer
  • All of Microsoft
  • My Role
    • All in My Role
    • Citizen Developer
  • Focus
    • All in Focus
    • Microsoft Ignite 2026
    • Generative Pages and Apps
    • Microsoft Copilot Studio
    • Copilot Studio - Agent Step-by-Step
    • What's Hot
    • M365 Release
Timespan
explore our new search
Power Apps environment variables for app settings
Power Apps

Power Apps environment variables for app settings

by HubSite 365 about Pragmatic Works

Power Apps makers can use environment variables to change URLs and feature flags when moving a solution from development to test.

Key insights

  • Create an environment variable in a solution with New > More > Environment Variable.
  • A current value overrides the default; the default is used when no current value is set.
  • Power Automate exposes environment variables in the dynamic content selector under Parameters.
  • Canvas apps can read the Environment Variable Definitions and Environment Variable Values tables.
  • A Yes/No variable may temporarily disappear from flow dynamic content; refreshing the page can help.

Power Apps environment variables let makers keep settings such as site URLs and feature flags configurable as a solution moves between environments. They matter to app makers and flow authors who want a development solution to use different values in test without changing the app or flow logic. Pragmatic Works demonstrates the setup and deployment process in a YouTube video.

What's new

Environment variables provide a way to separate a value that changes by environment from the app or flow that uses it. A site URL can point to a development site in one environment and a test site in another, while the solution continues to use the same variable name. A Yes/No variable can also act as a feature flag, controlling whether a canvas app button or screen is visible.

Each variable has a definition and may have a current value as well as a default value. The definition includes details such as its name and data type. The default value is used when no current value has been configured; a current value takes precedence. This distinction matters during deployment: the variable can have a safe default while a target environment receives its own value.

Environment variables are solution components. During import, the maker can supply values for the target environment, rather than editing the app or flow to replace a development URL. The demonstration also shows a managed solution import and changing a value after import.

Who it is for and what you need

This approach is useful for makers building canvas apps and cloud flows in solutions, and for people responsible for moving those solutions between development and test. It is especially relevant when a URL or feature setting differs by environment. The example uses a SiteURL variable and a Yes/No feature flag.

Start from a solution in Power Apps. The variable is created within the solution, and the app or flow that uses it is also part of the solution workflow. The demonstration uses Dataverse environment variable tables for direct canvas app access. It also uses a solution import into a test environment to set target values.

For a Yes/No feature flag, decide which behavior should apply when no current value exists. In the example, the default is No while the development current value is Yes. That lets the maker test the feature in development while retaining a different default for deployment.

How it works

  1. Open the solution and select New > More > Environment Variable. Give the variable a display name and description, then choose its data type, such as Yes/No for a feature flag.
  2. Set a default value. Add a current value if the environment needs to override that default. In Advanced settings, choose whether to export the current value; the demonstration notes that not exporting it removes that current value from the exported solution.
  3. In a solution cloud flow, select a trigger or action parameter and open the dynamic content selector. Environment variables appear under Parameters; search by the variable name if needed. The example assigns SiteURL to a flow variable.
  4. In a canvas app, add the Environment Variable Definitions and Environment Variable Values tables as data sources. Use a formula to look up the matching schema name and retrieve the current value, with the definition's default value as a fallback when no current value is present.
  5. Use the retrieved value in the app, such as to set a button's Visible property from a feature flag. Publish the app and solution changes, export the solution, and import it into the target environment. During import, set values such as the test URL or feature flag value.

In the demonstrated app formula, the lookup uses the variable's schema name to find its value. A Coalesce pattern checks the current value first and falls back to the default. For a Yes/No value used in visibility logic, make sure the comparison matches the value returned by the table; the example checks whether the value equals Yes.

In the flow, dynamic content is the direct route for ordinary use. If a flow needs additional information from the variable tables, the demonstration mentions Dataverse List rows or Get a row by ID as alternatives.

Limitations and alternatives

The demonstration reports inconsistent discovery of Yes/No variables in Power Automate dynamic content: a parameter may not appear or may be reported as missing. Refreshing the page made the variable appear in the example. If it remains unavailable, one suggested workaround is to store the flag as text and compare it with Yes, No, True, or False.

After importing a managed solution, its variable may not be editable from the managed solution view. The demonstration changes the current value through the Environment Variable Values table by editing the row. It cautions that this may introduce an unmanaged solution layer, so a further solution promotion with the desired value may be preferable.

Before deploying, check that the current value will be exported as intended and that the target environment receives the right value. Also publish recent changes before exporting, and verify the imported app or flow uses the intended setting. For SharePoint scenarios, data source environment variables are introduced as another option for managing environment-specific data sources.

Sources

Frequently asked questions

How do I create an environment variable in Power Apps?

Open a solution and select New > More > Environment Variable. Set its name, data type, default value, and any current value.

How do I use an environment variable in Power Automate?

In a solution cloud flow, choose the variable from the dynamic content selector under Parameters. Search by its name if it does not appear immediately.

How can a canvas app use an environment variable as a feature flag?

Add the Environment Variable Definitions and Environment Variable Values tables as data sources, look up the variable by schema name, and use its value in a property such as Visible.

Can I change an environment variable during solution import?

Yes. During the demonstrated managed solution import, the maker sets values for the target environment, including a site URL and a Yes/No feature flag.