Set or Update environment variables by using Power Automate 2025

By
On:

Set or Update environment variables by using power automate

For any Power Platform solution, environment variables are essential. They configure everything from API keys to database connections, adapting your apps and flows for different stages like development, testing, and production. Yet, managing them effectively is a common headache.

Here’s why managing variables on the Power Platform can be so frustrating:

Dynamic Update Struggles: Updating variables often means redeploying entire solutions, disrupting live services. Achieving dynamic updates without downtime is a significant hurdle.

Cross-Environment Headaches: Ensuring variables correctly carry over and apply to the right environment when solutions are imported is a frequent point of failure.

Inconsistent Methods: There’s no single, unified way to handle variables across Power Apps, Power Automate, and Dataverse, leading to confusion and inconsistencies.

Solution: Set or Update environment variables by using power automate

Power Automate flow that enables single-click updates, ensuring fast, efficient, and secure management without manual intervention. This flow directly addresses the pain points of inconsistent methods, security risks, cumbersome updates, and deployment issues by centralizing and automating the process.

Set or Update environment variables by using power automate

This Power Automate flow is designed to dynamically update the value of a specific Dataverse environment variable based on a text input provided by the user when the flow is run.


1. Manually Trigger a Flow

The flow starts with a manual trigger, as shown in image_ff4463.png.

  • Action: Manually trigger a flow
  • Purpose: This allows a user to start the flow on demand.
  • Input: It’s configured with a single text input field named Environment. The user will enter the target environment name here (e.g., “SIT”, “PROD”, “DEV”) when they run the flow. This input is used later in the Switch action to control the flow’s logic.

2. Find the Environment Variable to Update

Next, the flow uses the List rows action to find the specific environment variable that needs to be updated. It identifies the correct variable by looking up its unique schema name, which is a stable and reliable method.

  • Action: List rows (renamed to “Filtering Environment Value based on schema name”)
  • Table name: Environment Variable Values
  • Filter rows: It uses an OData query to filter the records: EnvironmentVariableDefinitionId/schemaname eq 'rj_EnvironmentVariableText'. This query finds the environment variable value whose parent definition has the schema name rj_EnvironmentVariableText.
  • Expand Query: EnvironmentVariableDefinitionId. This is necessary to access the schemaname from the related EnvironmentVariableDefinition table in the filter query.
  • Purpose: This step precisely locates the environment variable record we want to modify and gets its unique ID (environmentvariablevalueid), which is needed for the update step.

3. Switch Control for Conditional Logic

A Switch control is used to direct the flow down a specific path based on the user’s input from the trigger.

  • Action: Switch
  • On: The switch operates on the Environment input provided by the user in the first step.
  • Cases: As seen in the overall flow diagram (image_ff4424.png), there are different branches (cases) for different inputs, such as “Case-SIT” (which runs if the input Equals “SIT”), “Case-PROD”, and a “Default” case for any other values.

4. Update the Environment Variable Value

Inside each case of the Switch, an Update a row action is performed to change the environment variable’s value. This action is placed inside an Apply to each loop because the “List rows” action always returns an array (a list of items), even if it only finds one.

  • Action: Update a row (renamed to “Updating Environment Variable”)
  • Table name: Environment Variable Values
  • Row ID: This is the unique identifier of the environment variable record to be updated. It is dynamically taken from the output of the “Filtering Environment Value…” step.
  • Value: This is the new value for the environment variable. This value is hardcoded differently in each branch of the Switch. For example, in the “Default” branch shown in the image, the value is set to “DEV”. In the “SIT” branch, it would be set to a SIT-specific value, and in the “PROD” branch, it would be set to a PROD-specific value.

In summary, the flow takes a simple text input like “SIT”, finds a specific environment variable by its schema name, and updates its value to the one corresponding to the “SIT” case. This provides a simple and effective way to manage configuration across different environments.

✨ Thanks for reading! ✨

I hope you found this blog on the Microsoft Power Platform helpful! From Power Apps, Power Automate (Cloud & Desktop), Canvas Apps, Model-driven Apps, Power BI, Power Pages, SharePoint, Dynamics 365 (D365), Azure, and more, I cover a wide range of topics to help you harness these powerful tools. Don’t miss out on future tips, tutorials, and insights—hit that subscribe button to get the latest posts right to your inbox. 💌💬 I’d love to hear your thoughts! Drop a comment below with your questions, ideas, or feedback—let’s get the conversation started!🔗 Let’s connect and grow together!


Follow me, Ravindra Jadhav, on your favorite platforms for even more content and updates on Microsoft Power Platform and related technologies:

💼 LinkedIn – Let’s network and share ideas!

💻 GitHub – Explore my projects and code.

🐦 Twitter – Stay updated with quick tips and industry news.

📺 YouTube – Watch tutorials and deep dives on Power PlatformPower AppsPower Automate, and more! Let’s build something amazing together with Power Platform and Azure! 🚀 

Set or Update environment variables by using power automate

Set or Update environment variables by using power automate

Dynamically Update Environment Variable Value

Environment Variable Configuration Manager

Conditional Update of an Environment Variable

Set Environment Variable Based on Manual Input

Update App Configuration

Set Target Environment (SIT/PROD)

Switch Environment Variable Value

Update Configuration by Schema Name

Utility: Set Environment Variable via Manual Trigger

Dataverse: Update Environment Variable by Schema

Change Application Environment

Environment Setup Utility

Select Configuration (SIT/PROD/DEV)

Run to Set Environment

Dynamically Update Environment Variable Value

How to change environment variable value in a flow

Filter environment variable by schema name

Power Automate expand query on lookup field

Dynamically set connection string in Power Automate

Power Automate update variable based on input

Set or Update environment variables by using power automate

Set or Update environment variables by using power automate

Set or Update environment variables by using power automate

Leave a Comment