Now it is time to be Curious about Power Platform Environment Variables!

The Power Platform Environment Variables is yet another key component for enterprise-level application development best practice delivered with the need for no code to use.

Let me run you through the History, why, use cases, and in the end, give u a step-by-step guide with a video demo on how to use the Power Platform Environment Variable when connecting to the SharePoint list in a Canvas App

History on Environment Variables

An Environment variable is a dynamic-named value that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs. They were introduced in their modern form in 1979 with Version 7 Unix, so they have always been around and have always served the same purpose.

An environment variable is a variable whose value is set outside the program, typically through a functionality built into the operating system or microservice. An environment variable is made up of a name/value pair and available for reference.

Use cases for Power Platform environment variables

During application initialization, environment variables are typically read by the application and used for different purposes. Use cases for environment variables include but are not limited to data such as:

  1. Execution mode (e.g., production, development, staging, etc.)
  2. Domain names
  3. API URL/URI’s
  4. Group mail addresses, such as those for marketing, support, sales, etc.
  5. Service account names

The primary use case for environment variables is to limit the need to modify and re-release an application due to changes in configuration data. Fx. if an API URL endpoint changes there’s no need for source code alterations, testing, and deployment of the modified application.

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 affected application function(s) to ensure the application still works as expected.

Next, let’s look at one example on how to utilize environment variables in the Power Platform when using it for connection info for the SharePoint Connector within a Canvas app.

Automatically create Power Platform environment variables when connecting to SharePoint list in a Canvas App

First Enable Canvas app using Power Platform environment variables, Edit or create a canvas app from a solution.

  1. Select File > Settings > Advanced settings and enable the setting to Automatically create environment variables when adding data sources.
  2. Save the App to save the new setting.
  3. Close the App and reopen (usually changes to settings first take affect when reopered
EnvVarStep1
Now it is time to be Curious about Power Platform Environment Variables! 13
  1. Add a new data source for SharePoint online.
  2. Select a SharePoint site, one or more lists, and then Connect
  3. A green notification appears to let you know that Environment Variable has been created
enviromentenvCreated
Now it is time to be Curious about Power Platform Environment Variables! 14

Thereafter the Environment variables containing the SharePoint connection details are stored in the solution and can be edited.

EnvVarStep3
Now it is time to be Curious about Power Platform Environment Variables! 15

The first time importing solutions into another environment, the solution import wizard will prompt you to set these specific environments connection details for SharePoint for this particular app.

EnvVarStep4
Now it is time to be Curious about Power Platform Environment Variables! 16

Below you will see a demo with setup and test on the entire thing:

Read the full details and multiple other options about Environment variables and usage in Microsoft Documentation source: Use environment variables , in the related topic of Connection references and this Microsoft blog post Announcing data source environment variables | Microsoft Power Apps

Technical details

Environment Variables are stored in Microsoft Dataverse where Microsoft has created two entities/tables named “Environment Variable Definitions” and “Environment Variable Values”.
The 2 entities (i.e. “Environment Variable Definitions” and “Environment Variable Values”) are related to each other. The “Environment Variable Definitions” has a 1:N or rather a 1:1 relation with the “Environment Variable Values” … you cannot have more than one value for one definition.

Power Platform Environment Variables
Power Platform Environment Variables

Leave a Reply