| Mohsin Ahmed

In this blog, we are going to look at environment variables in Power Platform and how they can be beneficial for applications deployment across multiple environments.

When developing applications that are intended to be deployed across a range of environments (Development, Test, Production), developers often require different configuration and input parameters for their applications. Hard coding these parameters within application code is not good practice because the code would need to be changed when deploying the application to various environments. This results in tight coupling of the parameters and the objects that use those parameters, which is what we want to avoid. Environment variables are meant to tackle this scenario. Environment variables are key value pairs, which can be used as parameters across various applications in the Power Platform. By using environment variables, we can change our application parameters on-the-fly, without having to modify the application code. This becomes especially useful when deploying the application across multiple environments or when application lifecycle management (ALM) routines have been put in place.

So, how do we go about creating environment variables?
The following are the steps to create an environment variable:

  1. Go to https://make.powerapps.com/
  2. Select your environment of choice from the environment dropdown at the top right corner of the page
  3. Go to “solutions” tab
  4. Choose your desired solution
  5. Select “new” button at the top right corner of the page
  6. Select environment variable from the dropdown list
You’ll now be greeted with the following form for creating an environment variable:
Environment Variables 1

You can give your variable a display name of choice. The name (unique name) field will be automatically populated for you based on the display name. However, you can customize the name as well. You can add a description for your variable, but it is not required. Then you will have to choose a data type for your variable. You can choose from the following options:

  • Decimal number
  • JSON
  • Text
  • Yes / No
  • Data Source
Then you can set a default value for your environment variable, which will be used when no “current value” is present for said variable on a particular environment. More on this later.
Once you are done with setting these fields, your form will look like the following:
Environment Variables 2
Now your environment variable is created, and it can be used across multiple applications in your environment.

The main benefit of environment variables is harnessed when applications utilizing environment variables are deployed across multiple environments. You can set different values for environment variables in each of your environments. This can be done when importing solutions containing environment variables into different environments. While importing a solution which contains any environment variable, you will have the option to provide a “current value” for respective variables, this is how you can set different values for your environment variables across multiple environments. You can also change values for environment variables in any environment by going to the solution(s) containing the respective variables and assigning new values to those variables.

Please note that environment variables can only be assigned new values while importing solutions into other environments when the exported solution containing the variable does not contain a “current value” for the variable. This can be done by going to the solution containing the variable, selecting the variable to open the environment variable form, then removing the variable’s “current value”, if any, from the solution. This removes the current value of the variable from the solution itself, but keeps the value stored in the current environment, so the variable can be continued to be used across multiple applications in the environment.

Environment Variables 3
We have now successfully utilized the power of environment variables in Power Platform and made our lives as developers easier!

Learn more about Imperium's Power App Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.

About The Blog

Stay updated with what is happening in the Microsoft Business Applications world and initiatives Imperium is taking to ease digital transformation for customers.

More About Us

We provide guidance and strategic oversight to C-Suite and IT Directors for on-going implementations. Feel free to give us a call.

1 331 250 27 17
Send A Message

Ready to Start?

Get a personalized consultation for your project.

Book a Meeting