title: Automate Azure Application Insights processes with Microsoft Flow description: Learn how you can use Microsoft Flow to quickly automate repeatable processes by using the Application Insights connector. services: application-insights documentationcenter: '' author: mrbullwinkle manager: carmonm ms.service: application-insights ms.workload: tbd ms.tgt_pltfrm: ibiza ms.devlang: na ms.topic: article ms.date: 06/25/2017 ms.author: mbullwin
Do you find yourself repeatedly running the same queries on your telemetry data to check that your service is functioning properly? Are you looking to automate these queries for finding trends and anomalies and then build your own workflows around them? The Azure Application Insights connector (preview) for Microsoft Flow is the right tool for these purposes.
With this integration, you can now automate numerous processes without writing a single line of code. After you create a flow by using an Application Insights action, the flow automatically runs your Application Insights Analytics query.
You can add additional actions as well. Microsoft Flow makes hundreds of actions available. For example, you can use Microsoft Flow to automatically send an email notification or create a bug in Visual Studio Team Services. You can also use one of the many templates that are available for the connector for Microsoft Flow. These templates speed up the process of creating a flow.
In this tutorial, you will learn how to create a flow that uses the Analytics auto-cluster algorithm to group attributes in the data for a web application. The flow automatically sends the results by email, just one example of how you can use Microsoft Flow and Application Insights Analytics together.
- Sign in to Microsoft Flow, and then select My Flows.
- Click Create a flow from blank.
-
Select Schedule, and then select Schedule - Recurrence.
-
In the Frequency box, select Day, and in the Interval box, enter 1.
-
Click New step, and then click Add an action.
-
Search for Azure Application Insights.
-
Click Azure Application Insights – Visualize Analytics query Preview.
To complete this step, you need an application ID and an API key for your resource. You can retrieve them from the Azure portal, as shown in the following diagram:
This example query selects the failed requests within the last day and correlates them with exceptions that occurred as part of the operation. Analytics correlates them based on the operation_Id identifier. The query then segments the results by using the autocluster algorithm.
When you create your own queries, verify that they are working properly in Analytics before you add it to your flow.
-
Add the following Analytics query, and then select the HTML table chart type.
requests | where timestamp > ago(1d) | where success == "False" | project name, operation_Id | join ( exceptions | project problemId, outerMessage, operation_Id ) on operation_Id | evaluate autocluster()
-
Click New step, and then click Add an action.
-
Search for Office 365 Outlook.
-
Click Office 365 Outlook – Send an email.
-
In the Send an email window, do the following:
a. Type the email address of the recipient.
b. Type a subject for the email.
c. Click anywhere in the Body box and then, on the dynamic content menu that opens at the right, select Body.
d. Click Show advanced options.
-
On the dynamic content menu, do the following:
a. Select Attachment Name.
b. Select Attachment Content.
c. In the Is HTML box, select Yes.
You can wait for the trigger to run this action, or you can run the flow immediately by running the trigger on demand.
When the flow runs, the recipients you have specified in the email list receive an email message that looks like the following:
- Learn more about creating Analytics queries.
- Learn more about Microsoft Flow.