Intermediate | Flow of the Week: Get notified when new Connectors are deployed in your Flow Environment
A recent ask from customers is to be notified when new connectors are provisioned within a Microsoft Flow environment. These requests may be related to updating Data Loss Prevention (DLP) policies or provide opportunities to take advantage of new connectors to drive more value for their business. For example, we recently released the popular ServiceNow and Workday connectors. Customers were very interested to know when these connectors were becoming available. While our team is consistent in blogging about new capabilities, we have had requests for more direct communication about these types of events.
Last week, the Flow team blogged about a new Flow Management connector. This connector provides many useful operations for Flow Administrators and power users. Using this connector we are able to retrieve a list of all connectors within a specific Flow environment and send email notifications to interested stakeholders when a new connector has been deployed. We have created a template to accelerate the amount of time it takes to use this functionality, but will walk through the steps to create this flow below.
We want to check every day to see if a new connector has been deployed to our Flow environment. The best way to do this is to use the Recurrence trigger and then set the Interval to 1 and Frequency to Day.
The next step we want to perform is to retrieve all connectors within our environment. We can accomplish this by using the List Connectors operation from the Flow Management connector. To add this connector to your flow, click on the + button followed by clicking on Add an action label and then search for Flow Management – List Connectors. With the List Connectors action on our flow, we can now configure it to target a specific environment that we are interested in.
Note: within this dropdown, you will only see environments that you have access to.
The List Connectors action is going to return an array that contains all connectors within the environment that we specify. Since we are only interested in new connectors, we want to filter our result set. We can perform this filtering by using the Filter array action. Our From input parameter needs to be set to our value that is being returned from the List Connectors action.
Now we also need to provide filter criteria so that we can exclude connectors that were previously deployed. In order to achieve this filtering, we are going to use an expression that takes advantage of the ticks() function. The ticks function takes in a datetime string and will convert it into the number of ticks since 1 January 1601. As part of the first ticks call, we will pass in the date created value for the connector. As a result, our expression (on left hand side) is: ticks(item()?['properties']?['createdTime']). Next we want to see if this value is greater than the the ticks of a previous day. Therefore, our expression on the right hand side is: ticks(addDays(utcNow(), -1, 'MM/dd/yyyy')). Within this expression we are using a couple additional function calls. Assuming that this process runs every day, we want to see if anything has changed since we ran this process yesterday. To accomplish this, we use the addDays function and provide the current timestamp in UTC and –1 as a value that represents yesterday.
In order to track the number of new connectors deployed in our environment, which we will also use when sending email digests, we need to create a couple variables. The first variable we are going to create is called NewConnectorCount. This variable is going to be an Integer and will have an initial value of 0.
The other variable we want to initialize is called Email Body. We will use this variable to store our content for the email digest we send at the end of the process.
We now have a filtered list of connectors that have been deployed since our last run, which would have been yesterday. In order to provide a rich experience, we will use HTML to wrap around connector details returned from our Filter array action. To do this we will use an Apply to each loop using the Body returned from the Filter array action as our input.
Within this loop, add a Compose action where we can add HTML markup around the Connector Display Name and Connection Created Time values. Below our Compose shape, we will increment our NewConnectorCount variable which will allow us to provide a running total of the amount of connectors that have been added.
Next, we want to construct emails based upon whether or not new connectors were found. We will use a condition for this purpose and check to see if our NewConnectorCount variable is greater than 0. If this is true, we will add some HTML markup to our Email Body variable to make our email more presentable. We will include the number of new connectors found by including the NewConnectorCount variable and we will aggregate our list of HTML-enriched connector details using the join(outputs('Create_HTML_Row'),'') expression. If there are no connectors found, we will update the same Email Body variable, but with a simpler message that indicates 0 Connectors have been added to our environment.
Our final step is to actually send the email using the Office 365 connector. Because we used variables earlier for our connector count and email body, we can create one connection and Send an email action and use those variables as dynamic content for our email.
We can now save our Flow and it will run for the first time.
If you end up with no new connectors within your results, you can modify the ticks(addDays(utcNow(), -1, 'MM/dd/yyyy')) expression in the Filter array action. to include a wider window (i.e. –7). If there were any new connectors deployed within the past 7 days, they should show up in the email digest.
In this blog post we explored the Flow Management connector and discovered how to use the List Connectors operation in order to provide some operational insights into our Flow environment. We are continuing to invest in our Flow Admin capabilities and this is another tool available to apply governance processes and create opportunities for your business by using the latest connectors. If you have ideas for Admin related templates or other feedback, please leave us comments below or post on our Community forum.