Environment variables in Dataverse allow you to store the connection reference or keys needed to be used inside the environment. They are more like a global variable that can be accessed within the Power Platform Environment. We can use this to store the values and use it for Power Platform Customizations.
Environment Variables
We can use the environment variables in Canvas Apps, Model Driven Apps, and Power Automate. These environment variables help avoid the hardcode values for configuration data that must be changed during the ALM operations. It allows you to modify the values while moving the solution to another environment.
From the Dataverse perspective, the Environment Variable has two tables: Environment Variable Definition and Environment Variable Values. The Environment Variable Definition table holds the definition, data type, name, and sometimes default values(if it has). The environment variable value table has the current values used inside the current environment. Environment Variable Definition has a 1:N relationship with the Environment Variable Value table.
Features of Environment Variables
1.Default value
It is part of the environment variable definition table. It is not required if it has current values.
If the value should be the same for all the environments, we may use default values because we can’t be able to modify them in the target environment.
2.Current Value
*It is part of the environment variable value table. It will override the default value. It is used as a value even if the default value contains a value.
*Remove the current value from the solution if you don’t want to use the value in the target environment.
*One Environment Variable can be used across multiple solution components.
*Six data types are supported by Environment Variable: Decimal Number, Text, JSON, Yes/No, Secret, and Data source.
->There are two types of values which are
*Default Value
*Current Value
Create a new Environment Variable
Go to the solution where you want to create a new environment variable.
*Click on + New → More → Environment Variable. A quick create form pops from the right.
*Add Display Name, Name, Data Type, and Value
Click on save and publish
I have created four environment variables: tenant id, client id, client secret, and scope. All are text data types.
Variable Name Variable Value
tenant_id tenant id of your org
client_id Client Id of your app
client_secret Client Secret of your app
scope https://graph.microsoft.com/.default
I got the values from my Azure AD App and stored them in the Environment Variables inside the Power Platform.
Note. You may use secret data type for client secret; for that, you must configure Azure Key Vault. As it is a learning purpose, I have used text data type.
For any Help or Queries Contact us on info@crmonce.com or +918096556344