Get List Of All Flows In The Environment With Number Of Actions In It

Problem

If you are a part of a big organization, with hundreds of FLOWs being used on daily basis and thousands of users who keep on generating huge amounts of data then it becomes very important for you to plan the usage capacity very carefully. Microsoft Power Automate is free to use under Office 365 licenses, and it also has its own per flow, per user licenses.

With Office 365 licenses there are certain limitations on how many actions can be executed in 24 hours per user. If you have Office 365 license, then it's 10,000 action requests per 24 hours. So, what happens if the limit reaches – the flows slows down and after limit crosses the flows stops and start failing until next day.

Solution

So how should you tackle this problem? Well, you have to first understand how many flows you have in your environment and how many actions there are in each of those flows.

We can get the list of FLOWs by creating a FLOW with specific actions. Microsoft has provided two connectors to manage or read data related to FLOWs and those are – Power Automate Management and Power Automate for Admins.

Let’s create a FLOW -> Navigate to Flow portal -> Create an instant FLOW -> Keep the trigger as manual -> Look for Power Automate Management connector -> look for List flows as Admin

Get list of all FLOWs in the environment with number of actions in it

This action will give us the list of all FLOWs from specific environment. If you want only your FLOWs to be listed, then you can use “List my Flows” action.

Select the environment from which you want to get the FLOWs, as shown below

Get list of all FLOWs in the environment with number of actions in it

Save the FLOW, run it and test it. Try to understand the response of the action. Check out how the data is being responded, what all fields are there, what all fields are important for you to extract from that JSON.

I have copied JSON below of one FLOW object from the array, and it contains fields such as name (this is FLOW ID), properties, displayname, state, triggers, and actions.

[
  {
    "name": "65d93579-09e3-468d-bc61-87c901a1a422",
    "id": "/providers/Microsoft.Flow/environments/Default-def3cd14-db5d-404b-b4b5-ef1169bd8df5/flows/65d93579-09e3-468d-bc61-87c901a1a422",
    "type": "Microsoft.Flow/environments/flows",
    "properties": {
      "apiId": "/providers/Microsoft.PowerApps/apis/shared_logicflows",
      "displayName": "Doc Approval FLOW 1",
      "state": "Stopped",
      "createdTime": "2021-11-19T10:13:27.2373241Z",
      "lastModifiedTime": "2021-11-26T06:46:35.16001Z",
      "flowSuspensionReason": "None",
      "environment": {
        "name": "Default-def3cd14-db5d-404b-b4b5-ef1169bd8df5",
        "type": "Microsoft.Flow/environments",
        "id": "/providers/Microsoft.Flow/environments/Default-def3cd14-db5d-404b-b4b5-ef1169bd8df5"
      },
      "definitionSummary": {
        "triggers": [
          {
            "type": "OpenApiConnection",
            "swaggerOperationId": "GetOnNewFileItems",
            "metadata": {
              "operationMetadataId": "ccc2eddc-95e0-4506-84c4-5841890c375d"
            }
          }
        ],
        "actions": [
          {
            "type": "If",
            "metadata": {
              "operationMetadataId": "2fab8aaa-83b4-4773-b5b3-74cf1cdd31c5"
            }
          },
          {
          }
        ]
      },
      "creator": {
        "tenantId": "def3cd14-db5d-404b-b4b5-ef1169bd8df5",
        "objectId": "83047c7c-4a6e-4e9c-80d5-e69e1ce0bdd9",
        "userId": "83047c7c-4a6e-4e9c-80d5-e69e1ce0bdd9",
        "userType": "ActiveDirectory"
      },
      "provisioningMethod": "FromDefinition",
      "flowFailureAlertSubscribed": true
    }
  }
]

State - will tell us if the FLOW is active/turned on or disabled/turned off.

Now let’s see how we can get the number of actions from above JSON. Again, this is straightforward, we will make use of length function and pass the actions object as input to it as shown below.

length(item()?['properties/definitionSummary/actions'])

Now you can generate HTML table out of above JSON and sent it as outlook email to yourself or to concerned users.

Now that you know the list of flows and number of actions in it you can follow below strategy to overcome capacity issue

  • Revisit the FLOW with highest number of actions in it - try to optimize the actions
  • Remove unwanted actions like compose and duplicate actions
  • Avoid condition action instead use expressions/functions like if, equals, greater, lesser, etc
  • Revisit the FLOW, which is being used the most, follow same strategy as mentioned above
  • Delegate the ownership of FLOW to other users or service account - Most of the FLOWs might be created with one account, and this will lead to a bottleneck in terms of measuring the capacity. Having FLOWs running with different accounts gives more capacity to utilize.

You can also check out the above configurations in detail from this youtube video.

That's it for this article. I hope this will help you guys. Thanks for reading.


Similar Articles