Preview: Environment variables overview
[This topic is pre-release documentation and is subject to change.]
Apps and flows often require different configuration settings across environments. Environment variables as configurable input parameters allow management of data separately compared to hard-coding values within your customization or using additional tools. Because they're solution components, performance is much better than importing configuration data as record data.
Benefits of using environment variables:
- No need to manually edit configurable values in a production environment.
- Configure one or more variables in one place and reference like a parameter across multiple solution components.
- Update values without a code change.
- Granular level security managed by Common Data Service.
- Unlimited number of variables (max solution size is 29 MB).
- Service the definitions and the values independently or together.
- Supported by SolutionPackager and DevOps tools enable continuous integration and continuous delivery (CI/CD).
- Support for localization.
- Can be used to control feature flags and other application settings.
- This is a preview feature.
- Preview features aren’t meant for production use and may have restricted functionality. These features are available before an official release so that customers can get early access and provide feedback.
How do they work?
Environment variables can be created and managed through the modern solution interface or by using code. A separate JSON file is created within your solution package for the values, which can also be managed in source control and modified in a build pipeline. Export to and import from Excel is supported. After creating environment variables, you can use them as inputs within plug-ins, flows, and other components.
Create an environment variable in Power Apps
- Sign in to Power Apps, and then on the left panes select Solutions.
- On the command bar, select New and then select Environment variable.
- On the left pane, complete the following fields, and then select Save:
Display name. Enter a name for the environment variable.
Name. The unique name is automatically generated from the Display name, but you can change it.
Data Type. Select from Decimal number, Text, JSON, or a Two option field.
Default Value. This field is part of the environment variable definition entity and is not required. Set a default value for the production environments or when the values don't need to be changed for different environments.
Current Value. Also known as the override value. This field is optional and is a part of the environment variable value entity. Set the value when you'd like to override the default value in your current environment. Remove the value from your solution if you don't want to use it in the next environment. The values are also separated into a separate JSON file within the solution.zip file that is exported.
Separation of default value and current value allows you to service the definition and the default value separately from the current value. It also allows us to extend the functionality in the future to support multiple values scoped to a specific run time context.
A value can't exist without a definition. The interface only allows creation of one value per definition.
A notification is displayed when the environment variables do not have any values. This is a reminder to set the values so that components dependent on variables do not fail. It also allows partners to ship variables without values and the customer is prompted to input the values.
We recommend partners build their own interfaces requiring the customers to provide the values. Notifications help prevent failures if this step is skipped.
Both the environmentvariabledefinition and environmentvariablevalue entities are user or team owned. When creating an application that uses environment variables, be sure to assign users the appropriate level of permission. More information: Security in Common Data Service.
- Caching. Plugins will need to run a query to fetch the values.
- Canvas apps and flows can consume environment variables just like entity record data.
- Azure Key Vault integration for secret management. Currently environment variables should'nt be used to store secure data such as passwords and keys.
- Data types are validated in the modern solution interface only, but not currently on the server during the preview.
- Dependencies are not enforced for certain component types.
- If using Excel to import environment variables, be sure to pre-pend the publisher prefix to the SchemaName.
Power Apps Blog: Environment variables available in preview! Use plug-ins to extend business processes Web API samples Create Canvas app from scratch using Common Data Service. Create a flow with Common Data Service