Power Platform Environment Variables Connection References
Solutions travel from development to test to production. Some settings must change at every stop, such as a SharePoint site address or an email account. Environment variables and connection references handle those changes without editing the app.
The Problem They Solve
Imagine a flow that reads files from a development SharePoint site. Moving the flow to production should point it at the production site. Editing the flow by hand after every deployment invites mistakes. A better design stores the address outside the flow and lets each environment supply its own value.
ONE SOLUTION
|
+---------------+----------------+
| | |
DEV TEST PROD
SiteURL=dev SiteURL=test SiteURL=live
Mailbox=dev@ Mailbox=qa@ Mailbox=support@
Environment Variables
An environment variable holds a configuration value inside a solution. It has a default value, which travels with the solution, and a current value, which belongs to one environment only.
Supported Data Types
| Type | Typical use |
|---|---|
| Text | Site addresses, labels, mailbox names |
| Decimal number | Thresholds, rates, limits |
| Yes/No | Feature switches |
| JSON | Structured settings |
| Data source | Connection details for a data source |
| Secret | Values kept in Azure Key Vault |
Creating a Variable
- Open your solution and select New, then More, then Environment variable.
- Enter a display name and pick the data type.
- Add a default value for development use.
- Save the variable.
- Reference it in apps and flows through the dynamic content or the Environment Variables data source.
Connection References
A connection holds the credentials that let a flow reach a service. A connection reference is a solution component that points to a connection without embedding it. The solution carries only the reference, and each environment links the reference to a local connection.
Flow: Send Invoice Email | uses v Connection Reference: "Outlook Shared Mailbox" | linked at import time to v DEV connection --> dev-service-account PROD connection --> prod-service-account
Many flows can share one connection reference. Changing the connection in one place updates every flow that uses it.
Deployment Walkthrough
- Build flows and apps in the development environment inside a solution.
- Replace hard-coded addresses with environment variables.
- Use connection references for every connector.
- Export the solution as managed.
- Import it into the test environment, and the import wizard asks for connections and variable values.
- Test, then repeat the import in production with production values.
Layman Example: A Phone Contact Card
A contact card on a phone holds a name and a number. You share the card with a friend, and the friend's phone dials from the friend's own SIM card. The card never carries your SIM. A connection reference works like the card, and the local connection works like the SIM that makes the call.
Using Pipelines and Automation
Power Platform pipelines and Azure DevOps or GitHub tasks can supply environment variable values and connection mappings automatically during deployment. Store values in a deployment settings file so every release repeats the same configuration without manual typing.
Good Practices
- Use service accounts for production connections so flows survive staff changes.
- Name variables with a clear prefix, such as Sales_SiteURL.
- Keep secrets in Azure Key Vault and reference them with secret-type variables.
- Review the variables and references list before every deployment.
- Document the expected value for each environment.
Troubleshooting Imports
An import that fails often lacks a connection or a variable value. Open the import wizard, link each connection reference to a working connection, and enter every missing value. After import, open the flows and confirm they are turned on. Check the run history of a test execution to verify that the flow reads the correct environment values.
Key Takeaways
Environment variables separate settings from logic, and connection references separate credentials from flows. Together they allow one solution package to run safely in every environment.
