Get Environment Variable Values
I got a query if I could produce a list of Environment variable values used in a specific Power Platform environment. This article demonstrates a setup of a Power Automate cloud flow which retrieves this information.
Setting the Scene
When you import a solution into a specific Power Platform environment you can use environment variables (aka parameters) to store configuration for that specific environment.
Lets say for example that you want to connect your Power Automate cloud flow to a different SharePoint Site Collection and document library for each of your environments. The values for the Site Address and the Library Name would be stored in two Data source environment variables.
You can visit your imported solution in the interface and peek what the current value is of your Environment variable. But what if you have a lot of variables in your solution?
Dataverse to the rescue
Like most stuff Microsoft Dataverse stores this type of configuration in Tables. After a bit of inspection I found the Environment Variable Value Table (environmentvariablevalue EntityType).
That table has a lot of columns, but I was mainly interested in schemaname, value, modifiedon & solutionid.
For this example I used a List rows from selected environment action in a Power Automate cloud flow to retrieve the information. However, you could also use other approaches as well. You can for example also interact via the Microsoft Dataverse Web API with this data.
Flow Setup
In this example I am only interested in values from a single Publisher and a single environment. The output will be stored as a CSV file on SharePoint Online.
1. Add a Manually trigger a flow action.
2. Add a List rows from selected environment action.
The Filter rows is used to only find variables from the Expiscornovus Publisher, which start with its own specific publisher prefix. In this case that prefix is exp_.
a. Select your preferred Environment
b. Select Environment Variable Values Table
c. Use the code snippet below for the Select columns
d. Use the code snippet below for the Filter rows
3. Add a Select action.
This action was used to get the email of my own account.
a. In the From use the body/value
b. Use the code snippet below for the Map
4. Add a Create CSV table action.
The output of the Body is sorted ascending on the Environment Variable Name key by using an expression with a sort function.
a. Use the code snippet below for the From
5. Add a Create file action.
This action creates a csv file in your preferred location in SharePoint Online.
a. Select your preferred site in the Site Address
b. Select your preferred Folder Path
c. Use the code snippet below for the File Name
d. Use the Output of the Create CSV Table in the File Content
That is it for the cloud flow setup of this example. The end result should look like the below.
Let me know in the comments what you think of this approach?