When working with an ATOP setup you might need to know in which environment the Power Automate flow is running. For my solution I needed to know the environment because each environment uses a different Gateway and database credentials. In this post, I will share with you how to find the environment GUID and name.
Creating the flow
- Create a flow and use the trigger Manually trigger a flow.
- Add the action Get Environments under Power Apps for Makers
- Add the Compose action and use the Workflow() expression, to get the current instance of the flow.
- Parse the Output in a Parse JSON action.
- Initialize a variable with the name environment as a string.
- The Value is the EnvironmentName form the Parse JSON output.
- Now you have the GUID of the current Environment in the variable.
- To find the name of the current environment we need to go through the results of the Get Environments action.
- Add a Condition control action and check if the environment variable is equal to the name from the Get Environments actions.
- This will automatically add an Apply to each, this is because the Get Environments action might return more than one environment.
- Add a Set variable action in the If yes section and set the variable environment to displayName.
- Now you have the Name of the current Environment in the variable.
- The final step is to add a Switch control and switch based on the name of the current environment.
- The flow will now look like this.