In my previous post on creating a flow run management app I stopped at the point where I collected the flow runs for a specific flow in a specific environment. In this post the details on that step.
Creating a custom connector
To create a custom connector we will need to do a couple of things.
Find an API that can give us the flow run details
Setup permissions to access the API
Create the custom connector
The Azure Management API
After looking around for a bit I found the Azure Management API that can give me the flow runs. There are some limitations to be aware of, but we can deal with that.
The way APIs work are that you send a request to a URL and then you get some data back or something might be done. The API I'm looking at is no different.
Using the following endpoint, I can get all the runs for a specific flow in a specific environment within my Power Platform.
https://management.azure.com/providers/Microsoft.ProcessSimple/scopes/admin/environments/{environment}/flows/{flow}/runs
One of the limitations that we will quite quickly run into is that only the most recent 50 flow runs are returned. Within the data returned however there is also another URL included that gives us access to the next 50 flow runs. So even though my prototype potentially didn't collect all flows for flows that run more than 50 times within each period of checking for flow runs, the Pro version that we have developed can handle that perfectly.
Setup permissions
To setup the permissions to the API, I will create an app registration with Azure.
To create the new app registration simply click on New registration.
Once the app registration has been created. You can collect the Application (client) ID and the Directory (tenant) ID. We will need these later when we create our custom connector.
Then within the API permissions we need to add user_impersonation permissions to the app registration.
Later on when we create the connector we will supply the client ID and the tenant ID which then gives our connector access to the API and we can get our flow runs.
Before we can create the custom connector, I'm also goin to generate a secret. When you generate the secret make sure that you keep a copy of the Secret Value (Not the Secret ID!!), as this is only given to you once.
Creating the connector
Now we are ready to create our custom connector.
We want to make our custom connector part of the solution, so that we can deploy it to different environment. Yes, we could also send the connector to Microsoft so that they could create this as a standard connector.
You could now upload a swagger file that I could provide but it is actually quite useful to understand how to create a custom connector, so I'm going to create a new connector from scratch.
The first step is to supply the general information. This is where we can control the icon of the connector and the colours of the connector as they will appear within actions in my flows.
Feel free to use custom icons and colours, I'm going to keep the standard custom connector settings here. Then the Host needs to be set to management.azure.com. This is the host part of my end point that I mentioned near the beginning of this post.
Configuring Security in the custom connector
Now we need to go back to our earlier notes. We will need the client ID, the secret value and the Tenant ID.
Also don't forget to set the resource URL to https://management.zore.windows.net/
Once that is complete we just need to add our get flow runs action and then our custom connector is nearly ready to us.
Creating the Get Flow Runs Action
Within the Definition tab we can add a new action and then we will need to supply the Summary and the Operation ID. The operation ID is comparable to an internal name with SharePoint columns. The Operation ID has to be unique if you create multiple actions.
Then in the request section we need to specify the details of our endpoint.
By clicking on the Import form sample the following pane will appear.
This is where we can use the following url.
https://management.azure.com/providers/Microsoft.ProcessSimple/scopes/admin/environments/{environment}/flows/{flow}/runs?api-version=2016-11-01
The above you will need to get right. So don't forget the Verb/Method or the Headers.
Now our action is ready, however we want to make this action a bit more user friendly.
As you can see there are 5 parameters that a user will have to complete.
environment
flow
api-version
Content-Type
Accept
The first two parameters we will want to ask the Power Automate developer for, but the other options we can just set to default values.
Simply click on the down arrow for the blue blocks and then edit the parameters. This way we can make the parameter have a default value and make the parameter invisible.
Now all we have to do is update the connector (click the Update connector link at the top) and test our step in the Test tab.
Once the connector has been saved, you can build the flows as described in my step by step guide to creating a flow run management app.
Hi,can you please tell what condition you have passed in environment and flow parameters of get flow runs action?