Power Platform Environment Variables
Introduction
Environment Variables are used by software developers to ensure they don’t have to modify their code from one environment to another. So, environment variables store the keys and values of various input parameters for your application.
Basically, environment variables consist of two parts the definition and the value. For a definition, there is some information related to it, like display name, description, and data type (decimal number, JSON, text, Yes or No, and data source).
Figure 1: Create new environment variables
Benefits of using environment variables:
- The user can reuse them any time at any platform PowerApps, power automate.
- The user can replace parameter values while importing solutions to other environments.
A simple example of using environment variables:
First, we can create environment variables just in the solution, so here I am creating a new solution.
Figure 2 : Create a new solution
Then inside the solution, user can create the environment variables: New >> More >> Environment Variables
Figure 3: Create variables inside the solution
So, for example, in the photo above, there is 2 variables created: Company address and Company name.
After that, the user can use these variables for example, in the flow. So, here in the photo below, are variables used in the block to send email.
Figure 4: Use variables inside flow
Why use Power Platform Environment Variables?
Modifying and releasing application code is complicated and increases the risk of introducing undesirable side effects into production.
When the URL is defined by an environment variable instead of the application, the change process consists of checking the validity of the new URL, updating the corresponding environment variable using an operating system command or updating a configuration file, and testing the affected application function(s) to ensure the application still works as expected.