Using Environment variables in your Power Apps solution

Quite often you need to have your app look and behave a bit differently depending on the current Environment context. I recently had to implement simple functionality where the user is directed to a Power BI report page on a click of a button. That’s simple enough using the Launch function in Power Apps, but in my case we were utlizing dev, test, and prod environments and the link used should target development, test, and production Power BI workspaces accordingly.

To solve this, I added a new Environment variable to the Solution.

image
image

I left Default Value blank and entered the URL to the Power BI report in the development workspace as the Current Value. I can then later update the Current Value in test and production Environments accordingly.

Next step is to edit your app so that you can access the new Environment variable. Go ahead and add Environment Variable Definitions and Environment Variable Values as data sources in your app.

image

After this, you can reference desired variable value like this:

LookUp(‘Environment Variable Values’, ‘Environment Variable Definition’.’Display Name’ = “Raportti URL”)

By using Environment Variables in your solution, you can easily separate environment specific details out of your app to a separately maintainable configuration location.

2 Comments

  1. Sandhya says:

    Same expression I have used to pass value from Environment variable to BackColor custom property for my banner color, it is showing error

    Like

    1. terhoantila says:

      I haven’t tried using environment variables in Color types in canvas apps. Perhaps you can try using a separate environment variable for each channel (red, green, blue, alpha) 🤔

      Like

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s