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.

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 )

Google photo

You are commenting using your Google 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