A Guide to Disabling Cloud Flows Using the Power Automate Management Connector

Some use cases, like Data Migration or Cleansing requires to temporarily disable/enable the cloud flows in bulk, the power automate management connector helps doing it with ease.

Refer the link for more information Power Automate Management

Below is the flow that can do the job, this can be refactored per ones needs.

Created a manual trigger and the first action is the list Flows as Admin (V2)

Note only system admin of an environment can use the action refer details here https://learn.microsoft.com/en-us/connectors/flowmanagement/#list-flows-as-admin-(v2)

Simply select the environment and then try and access the Environment Id using the Parse JSON and then use compose action with below expression.

body('Parse_JSON_|_Get_environment_id')?[0]?['properties']?['environment']?['name']

The List flows as admin (V2) action results in all the cloud flows that is present in the environment, this can be filtered out to a finer list of the cloud flows that requires to be turned off. In this case, I do not want the current flow that is executing to be turned off, so I simple filter the array to skip it using the Filter array action.

This is just an example, how ever one can extend the Filter array action to skip more flows.
Next step, is to use the list that the Filter array action returned and loop through the list and disable the flows using the Turn Off Flow action from the power automate management connector.

This actually completes the job of disabling flows, how ever notifying it to users or the team would be nice one to have. Multiple ways to do so, either an email, or post in teams or an In App notifications. In this case, I am going to post an In App notification.
The idea is to show a notification message in the model driven app and redirect users to the list of cloud flows inside solution to take a look at flows that are disabled.

So, lets get the default solution id for the same

Once the solution id is fetched the notification message can be composed like below

Then I use a Add a new Row action in dataverse to create a record in the notification table

The flow can be triggered to turn off the flow, in this case except the current flow, the rest is turned off.

Notification in Model driven app.

Below diagram indicates an overview of how the actions have been used. Thanks to this amazing tool https://github.com/modery/PowerDocu which was used to document the flow