Environment variables overview
Effective November 2020:
- Common Data Service has been renamed to Microsoft Dataverse. Learn more
- Some terminology in Microsoft Dataverse has been updated. For example, entity is now table and field is now column. Learn more
This article will be updated soon to reflect the latest terminology.
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 row 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.
- Enter different values while importing solutions to other environments.
- Update values without a code change.
- Granular level security managed by Microsoft Dataverse.
- 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.
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 columns, 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 column.
Default Value. This column is part of the environment variable definition table 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 column is optional and is a part of the environment variable value table. 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.
Enter new values while importing solutions
The modern solution import interface includes the ability to enter values for environment variables. This sets the value property on the
You will not be prompted if the environment variables already have either a default value or value present; whether values are part of your solution or are already present in Dataverse.
You may remove the value from your solution before exporting the solution. This ensures the existing value will remain in your development environment, but not get exported in the solution. This approach allows a new value to be set while importing the solution into other environments.
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 tables 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 Dataverse.
- Caching. Plugins will need to run a query to fetch the values.
- Canvas apps and flows can consume environment variables just like table row 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.