Skip to content

Commit 75c94e2

Browse files
committed
Add flow-usage and update TOC
1 parent 6a84f7b commit 75c94e2

File tree

3 files changed

+195
-167
lines changed

3 files changed

+195
-167
lines changed

articles/data-explorer/flow-usage.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
---
2+
title: Use the Microsoft Flow connector to run Kusto queries and commands automatically as part of a scheduled or triggered task
3+
description: Learn some common Microsoft Flow connector usage examples.
4+
author: orspod
5+
ms.author: orspodek
6+
ms.reviewer: dorcohen
7+
ms.service: data-explorer
8+
ms.topic: example-scenario
9+
ms.date: 03/15/2020
10+
---
11+
12+
# Microsoft Flow connector (Preview) usage examples
13+
14+
The Microsoft Flow connector enables you to run Kusto queries and commands automatically as part of a scheduled or triggered task, using [Microsoft Flow](https://flow.microsoft.com/). This document contains several common Microsoft Flow connector usage examples.
15+
16+
For more information, see [Microsoft Flow connector (Preview)](flow.md).
17+
18+
## Usage examples
19+
20+
1. [Microsoft Flow connector and SQL](#example-1-microsoft-flow-connector-and-sql)
21+
1. [Push data to Power BI dataset](#example-2-push-data-to-power-bi-dataset)
22+
1. [Conditional queries](#example-3-conditional-queries)
23+
1. [Email multiple Azure Data Explorer Flow charts](#example-4-email-multiple-azure-data-explorer-flow-charts)
24+
1. [Send a different email to different contacts](#example-5-send-a-different-email-to-different-contacts)
25+
1. [Create a custom HTML table](#example-6-create-a-custom-html-table)
26+
27+
## Example 1: Microsoft Flow connector and SQL
28+
29+
Use the Microsoft Flow connector to query your data and aggregate it in an SQL database.
30+
31+
> [!Note]
32+
> SQL insert is done separately for each row. Only use the Microsoft Flow connector for small amounts of output data.
33+
34+
![alt text](./Media/flow/flow-sqlexample.png "flow-sqlexample")
35+
36+
> [!IMPORTANT]
37+
> In the *Cluster Name* field, enter the cluster URL.
38+
39+
## Example 2: Push data to Power BI dataset
40+
41+
The Microsoft Flow connector can be used together with the Power BI connector to push data from Kusto queries to Power BI streaming datasets.
42+
43+
1. Create a new *Run query and list results* action.
44+
1. Select **New step**.
45+
1. Select **Add an action** and search for *Power BI*.
46+
1. Select **Power BI**.
47+
1. Select **Add rows to a dataset**.
48+
49+
![alt text](./Media/flow/flow-powerbiconnector.png "flow-powerbiconnector")
50+
1. Enter the *Workspace*, *Dataset*, and *Table* to which data will be pushed.
51+
1. From the dynamic content dialog, add a *Payload* containing your dataset schema and the relevant Kusto query results.
52+
53+
![alt text](./Media/flow/flow-powerbifields.png "flow-powerbifields")
54+
55+
Flow automatically applies the Power BI action for each row of the Kusto query result table.
56+
57+
![alt text](./Media/flow/flow-powerbiforeach.png "flow-powerbiforeach")
58+
59+
## Example 3: Conditional queries
60+
61+
The results of Kusto queries can be used as input or conditions for the next flow actions.
62+
63+
In the following example, we query Kusto for incidents that occurred during the last day. For each resolved incident, a slack message is posted and a push notification is created.
64+
For each incident that is still active, Kusto is queried for more information about similar incidents. It sends that information as an email, and opens a related TFS task.
65+
66+
Follow these instructions to create a similar Flow:
67+
68+
1. Create a new *Run query and list results* action.
69+
1. Select **New step**.
70+
1. Select **Condition control**.
71+
1. From the dynamic content window, select the parameter you want to use as a condition for next actions.
72+
1. Select the type of *Relationship* and *Value* to set a specific condition on the given parameter.
73+
74+
![alt text](./Media/flow/flow-condition.png "flow-condition")
75+
76+
Flow applies this condition on each row of the query result table.
77+
1. Add actions for when the condition is true and false.
78+
79+
![alt text](./Media/flow/flow-conditionactions.png "flow-conditionactions")
80+
81+
You can use the result values from the Kusto query as input for the next actions. Select the result values from the dynamic content window.
82+
In the example below, a *Slack - Post Message* action and *Visual Studio - Create a new work item* action containing data from the Kusto query were added.
83+
84+
![alt text](./Media/flow/flow-slack.png "flow-slack")
85+
86+
![alt text](./Media/flow/flow-visualstudio.png "flow-visualstudio")
87+
88+
In this example, if an incident is still active, query Kusto again to get information on how incidents from the same source were solved in the past.
89+
90+
![alt text](./Media/flow/flow-conditionquery.png "flow-conditionquery")
91+
92+
> [!IMPORTANT]
93+
> In the *Cluster Name* field, enter the cluster URL.
94+
95+
Visualize this information as a pie chart and email it to the team.
96+
97+
![alt text](./Media/flow/flow-conditionemail.png "flow-conditionemail")
98+
99+
## Example 4: Email multiple Azure Data Explorer Flow charts
100+
101+
1. Create a new Flow with "Recurrence" trigger, and define the interval of the Flow and the frequency.
102+
1. Add a new step, with one or more *Kusto - Run query and visualize results* actions.
103+
104+
![alt text](./Media/flow/flow-severalqueries.png "flow-severalqueries")
105+
1. For each *Kusto - Run query and visualize result*, define the following fields:
106+
* Cluster URL (in the *Cluster Name* field)
107+
* Database Name
108+
* Query and Chart Type (HTML Table/ Pie Chart/ Time Chart/ Bar Chart/ Enter Custom Value).
109+
110+
![alt text](./Media/flow/flow-visualizeresultsmultipleattachments.png "flow-visualizeresultsmultipleattachments")
111+
112+
> [!IMPORTANT]
113+
> In the *Cluster Name* fields, enter the cluster URL.
114+
115+
1. Add a *Send an email* action.
116+
* In the *Body* field, insert the required *body* so that the visualized result of the query is included in the body of the email.
117+
* To add an attachment to the email, add *Attachment Name* and *Attachment Content*.
118+
![alt text](./Media/flow/flow-emailmultipleattachments.png "flow-emailmultipleattachments")
119+
120+
Results:
121+
122+
![alt text](./Media/flow/flow-resultsmultipleattachments.png "flow-resultsmultipleattachments")
123+
124+
![alt text](./Media/flow/flow-resultsmultipleattachments2.png "flow-resultsmultipleattachments2")
125+
126+
## Example 5: Send a different email to different contacts
127+
128+
You can leverage Microsoft Flow to send different customized emails to different contacts. The email addresses and the email contents are a result of a Kusto query.
129+
130+
Example:
131+
132+
![alt text](./Media/flow/flow-dynamicemailkusto.png "flow-dynamicemailkusto")
133+
134+
> [!IMPORTANT]
135+
> In the *Cluster Name* field, enter the cluster URL.
136+
137+
![alt text](./Media/flow/flow-dynamicemail.png "flow-dynamicemail")
138+
139+
## Example 6: Create a custom HTML table
140+
141+
You can leverage Microsoft Flow to create and use custom HTML elements, such as a custom HTML table.
142+
143+
The following example demonstrates how to create a custom HTML table. The HTML table will have its rows colored by log level (the same as in Azure Data Explorer).
144+
145+
Follow these instructions to create a similar Flow:
146+
147+
1. Create a new *Kusto - Run query and list results* action.
148+
149+
![alt text](./Media/flow/flow-listresultforhtmltable.png "flow-listresultforhtmltable")
150+
151+
> [!IMPORTANT]
152+
> In the *Cluster Name* field, enter the cluster URL.
153+
154+
1. Loop over the query results and create the HTML table body:
155+
1. To create a variable to hold the HTML string, select **New step**
156+
1. Select **Add an action** and search for *Variables*.
157+
1. Select **Variables - Initialize variable**.
158+
1. Initialize a string variable as follows:
159+
160+
![alt text](./Media/flow/flow-initializevariable.png "flow-initializevariable")
161+
162+
1. Loop over the results:
163+
1. Select **New step**.
164+
1. Select **Add an action**.
165+
1. Search for *Variables*.
166+
1. Select **Variables - Append to string variable**.
167+
1. Select the variable name that you initialized before, and create the HTML table rows using the query results.
168+
When selecting the query results, *Apply to each* is automatically added.
169+
170+
In the example below, the `if` expression is used to define the style of each row:
171+
172+
```if(equals(items('Apply_to_each')?['Level'], 'Warning'), 'Yellow', if(equals(items('Apply_to_each')?['Level'], 'Error'), 'red', 'white'))```
173+
174+
![alt text](./Media/flow/flow-createhtmltableloopcontent.png "flow-createhtmltableloopcontent")
175+
176+
1. Create the full HTML content:
177+
1. Add a new action outside *Apply to each*.
178+
In the following example the action used is *Send an email*.
179+
1. Define your HTML table using the variable from the previous steps.
180+
1. If you're sending an email, select **Show advanced options** and, under *Is HTML*, select **Yes**.
181+
182+
![alt text](./Media/flow/flow-customhtmltablemail.png "flow-customhtmltablemail")
183+
184+
Result:
185+
186+
![alt text](./Media/flow/flow-customhtmltableresult.png "flow-customhtmltableresult")
187+

articles/data-explorer/flow.md

Lines changed: 2 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Common usage scenarios include:
2020
* Scheduling control commands on clusters
2121
* Exporting and importing data between Azure Data Explorer and other databases
2222

23+
For more information, see [Microsoft Flow connector usage examples](flow-usage.md).
24+
2325
## Log in
2426

2527
1. Log in to [Microsoft Flow](https://flow.microsoft.com/).
@@ -187,171 +189,6 @@ To fix a timeout issue, try to make your query more efficient so that it runs fa
187189

188190
For more information, read about [Query best practices]((https://docs.microsoft.com/azure/kusto/query/best-practices).
189191

190-
## Usage Examples
191-
192-
This section contains several common examples of using the Microsoft Flow connector.
193-
194-
### Example 1 - Azure Data Explorer (Kusto) flow and SQL
195-
196-
Use the Microsoft Flow connector to query your data and aggregate it in an SQL database.
197-
198-
> [!Note]
199-
> SQL insert is done separately for each row. Only use the Microsoft Flow connector for small amounts of output data.
200-
201-
![alt text](./Media/flow/flow-sqlexample.png "flow-sqlexample")
202-
203-
> [!IMPORTANT]
204-
> In the *Cluster Name* field, enter the cluster URL.
205-
206-
### Example 2 - Push data to Power BI dataset
207-
208-
The Microsoft Flow connector can be used together with the Power BI connector to push data from Kusto queries to Power BI streaming datasets.
209-
210-
1. Create a new *Run query and list results* action.
211-
1. Select **New step**.
212-
1. Select **Add an action** and search for *Power BI*.
213-
1. Select **Power BI**.
214-
1. Select **Add rows to a dataset**.
215-
216-
![alt text](./Media/flow/flow-powerbiconnector.png "flow-powerbiconnector")
217-
1. Enter the *Workspace*, *Dataset*, and *Table* to which data will be pushed.
218-
1. From the dynamic content dialog, add a *Payload* containing your dataset schema and the relevant Kusto query results.
219-
220-
![alt text](./Media/flow/flow-powerbifields.png "flow-powerbifields")
221-
222-
Flow automatically applies the Power BI action for each row of the Kusto query result table.
223-
224-
![alt text](./Media/flow/flow-powerbiforeach.png "flow-powerbiforeach")
225-
226-
### Example 3 - Conditional queries
227-
228-
The results of Kusto queries can be used as input or conditions for the next flow actions.
229-
230-
In the following example, we query Kusto for incidents that occurred during the last day. For each resolved incident, a slack message is posted and a push notification is created.
231-
For each incident that is still active, Kusto is queried for more information about similar incidents. It sends that information as an email, and opens a related TFS task.
232-
233-
Follow these instructions to create a similar Flow:
234-
235-
1. Create a new *Run query and list results* action.
236-
1. Select **New step**.
237-
1. Select **Condition control**.
238-
1. From the dynamic content window, select the parameter you want to use as a condition for next actions.
239-
1. Select the type of *Relationship* and *Value* to set a specific condition on the given parameter.
240-
241-
![alt text](./Media/flow/flow-condition.png "flow-condition")
242-
243-
Flow applies this condition on each row of the query result table.
244-
1. Add actions for when the condition is true and false.
245-
246-
![alt text](./Media/flow/flow-conditionactions.png "flow-conditionactions")
247-
248-
You can use the result values from the Kusto query as input for the next actions. Select the result values from the dynamic content window.
249-
In the example below, a *Slack - Post Message* action and *Visual Studio - Create a new work item* action containing data from the Kusto query were added.
250-
251-
![alt text](./Media/flow/flow-slack.png "flow-slack")
252-
253-
![alt text](./Media/flow/flow-visualstudio.png "flow-visualstudio")
254-
255-
In this example, if an incident is still active, query Kusto again to get information on how incidents from the same source were solved in the past.
256-
257-
![alt text](./Media/flow/flow-conditionquery.png "flow-conditionquery")
258-
259-
> [!IMPORTANT]
260-
> In the *Cluster Name* field, enter the cluster URL.
261-
262-
Visualize this information as a pie chart and email it to the team.
263-
264-
![alt text](./Media/flow/flow-conditionemail.png "flow-conditionemail")
265-
266-
### Example 4 - Email multiple Azure Data Explorer (Kusto) Flow charts
267-
268-
1. Create a new Flow with "Recurrence" trigger, and define the interval of the Flow and the frequency.
269-
1. Add a new step, with one or more *Kusto - Run query and visualize results* actions.
270-
271-
![alt text](./Media/flow/flow-severalqueries.png "flow-severalqueries")
272-
1. For each *Kusto - Run query and visualize result*, define the following fields:
273-
* Cluster URL (in the *Cluster Name* field)
274-
* Database Name
275-
* Query and Chart Type (HTML Table/ Pie Chart/ Time Chart/ Bar Chart/ Enter Custom Value).
276-
277-
![alt text](./Media/flow/flow-visualizeresultsmultipleattachments.png "flow-visualizeresultsmultipleattachments")
278-
279-
> [!IMPORTANT]
280-
> In the *Cluster Name* fields, enter the cluster URL.
281-
282-
1. Add a *Send an email* action.
283-
* In the *Body* field, insert the required *body* so that the visualized result of the query is included in the body of the email.
284-
* To add an attachment to the email, add *Attachment Name* and *Attachment Content*.
285-
![alt text](./Media/flow/flow-emailmultipleattachments.png "flow-emailmultipleattachments")
286-
287-
Results:
288-
289-
![alt text](./Media/flow/flow-resultsmultipleattachments.png "flow-resultsmultipleattachments")
290-
291-
![alt text](./Media/flow/flow-resultsmultipleattachments2.png "flow-resultsmultipleattachments2")
292-
293-
### Example 5 - Send a different email to different contacts
294-
295-
You can leverage Microsoft Flow to send different customized emails to different contacts. The email addresses and the email contents are a result of a Kusto query.
296-
297-
Example:
298-
299-
![alt text](./Media/flow/flow-dynamicemailkusto.png "flow-dynamicemailkusto")
300-
301-
> [!IMPORTANT]
302-
> In the *Cluster Name* field, enter the cluster URL.
303-
304-
![alt text](./Media/flow/flow-dynamicemail.png "flow-dynamicemail")
305-
306-
### Example 6 - Create Custom HTML Table
307-
308-
You can leverage Microsoft Flow to create and use custom HTML elements, such as a custom HTML table.
309-
310-
The following example demonstrates how to create a custom HTML table. The HTML table will have its rows colored by log level (the same as in Azure Data Explorer).
311-
312-
Follow these instructions to create a similar Flow:
313-
314-
1. Create a new *Kusto - Run query and list results* action.
315-
316-
![alt text](./Media/flow/flow-listresultforhtmltable.png "flow-listresultforhtmltable")
317-
318-
> [!IMPORTANT]
319-
> In the *Cluster Name* field, enter the cluster URL.
320-
321-
1. Loop over the query results and create the HTML table body:
322-
1. To create a variable to hold the HTML string, select **New step**
323-
1. Select **Add an action** and search for *Variables*.
324-
1. Select **Variables - Initialize variable**.
325-
1. Initialize a string variable as follows:
326-
327-
![alt text](./Media/flow/flow-initializevariable.png "flow-initializevariable")
328-
329-
1. Loop over the results:
330-
1. Select **New step**.
331-
1. Select **Add an action**.
332-
1. Search for *Variables*.
333-
1. Select **Variables - Append to string variable**.
334-
1. Select the variable name that you initialized before, and create the HTML table rows using the query results.
335-
When selecting the query results, *Apply to each* is automatically added.
336-
337-
In the example below, the `if` expression is used to define the style of each row:
338-
339-
```if(equals(items('Apply_to_each')?['Level'], 'Warning'), 'Yellow', if(equals(items('Apply_to_each')?['Level'], 'Error'), 'red', 'white'))```
340-
341-
![alt text](./Media/flow/flow-createhtmltableloopcontent.png "flow-createhtmltableloopcontent")
342-
343-
1. Create the full HTML content:
344-
1. Add a new action outside *Apply to each*.
345-
In the following example the action used is *Send an email*.
346-
1. Define your HTML table using the variable from the previous steps.
347-
1. If you're sending an email, select **Show advanced options** and, under *Is HTML*, select **Yes**.
348-
349-
![alt text](./Media/flow/flow-customhtmltablemail.png "flow-customhtmltablemail")
350-
351-
Result:
352-
353-
![alt text](./Media/flow/flow-customhtmltableresult.png "flow-customhtmltableresult")
354-
355192
## Limitations
356193

357194
1. Results returned to the client are limited to 500,000 records. The overall memory for those records can't exceed 64 MB and seven-minutes execution time.

articles/data-explorer/toc.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,13 @@
235235
- name: Bulk copy data using Azure Data Factory template
236236
href: data-factory-template.md
237237
- name: Run control commands using Azure Data Factory
238-
href: data-factory-command-activity.md
238+
href: data-factory-command-activity.md
239239
- name: Microsoft Flow connector
240-
href: flow.md
240+
items:
241+
- name: Microsoft Flow connector
242+
href: flow.md
243+
- name: Microsoft Flow connector usage examples
244+
href: flow-usage.md
241245
- name: Apache Spark Connector
242246
href: spark-connector.md
243247
- name: Connect from Databricks using Python

0 commit comments

Comments
 (0)