Azure Data Explorer connector to Power Automate (Preview)
The Azure Data Explorer Power Automate (previously Microsoft Flow) connector allows Azure Data Explorer to use the flow capabilities of Microsoft Power Automate. You can run Kusto queries and commands automatically, as part of a scheduled or triggered task.
- Send daily reports containing tables and charts.
- Set notifications based on query results.
- Schedule control commands on clusters.
- Export and import data between Azure Data Explorer and other databases.
For more information, see Azure Data Explorer Power Automate connector usage examples.
When you connect for the first time, you're prompted to sign in.
Select Sign in, and enter your credentials.
You can authenticate with user credentials, or with an Azure Active Directory (Azure AD) application.
Make sure your application is an Azure AD application, and is authorized to run queries on your cluster.
In Run control command and visualize results, select the three dots at the top right of the flow connector.
Select Add new connection > Connect with Service Principal.
Enter the required information:
- Connection Name: A descriptive and meaningful name for the new connection.
- Client ID: Your application ID.
- Client Secret: Your application key.
- Tenant: The ID of the Azure AD directory in which you created the application.
When authentication is complete, you'll see that your flow uses the newly added connection.
From now on, this flow will run by using these application credentials.
Find the Azure Kusto connector
To use the Power Automate connector, you need to first add a trigger. You can define a trigger based on a recurring time period, or as a response to a previous flow action.
Create a new flow, or, from the Microsoft Power Automate home page, select the My flows > + New.
Select Scheduled--from blank.
In Build a scheduled flow, enter the required information.
Select Create > + New step.
In the search box, enter Kusto, and select Azure Data Explorer.
When you open the Azure Data Explorer connector, there are three possible actions you can add to your flow. This section describes the capabilities and parameters for each action.
Run control command and visualize results
Use this action to run a control command.
- Specify the cluster URL. For example,
- Enter the name of the database.
- Specify the control command:
- Select dynamic content from the apps and connectors used in the flow.
- Add an expression to access, convert, and compare values.
- To send the results of this action by email as a table or a chart, specify the chart type. This can be:
- An HTML table.
- A pie chart.
- A time chart.
- A bar chart.
In the Cluster Name field, enter the cluster URL.
Run query and list results
This action sends a query to the Kusto cluster. The actions that are added afterwards iterate over each line of the results of the query.
The following example triggers a query every minute, and sends an email based on the query results. The query checks the number of lines in the database, and then sends an email only if the number of lines is greater than 0.
If the column has several lines, the connector will run for each line in the column.
Run query and visualize results
Use this action to visualize a Kusto query result as a table or chart. For example, use this flow to receive daily reports by email.
In this example, the results of the query are returned as an HTML table.
In the Cluster Name field, enter the cluster URL.
Email Kusto query results
You can include a step in any flow to send reports by email, to any email address.
- Select + New Step to add a new step to your flow.
- In the search box, enter Office 365 and select Office 365 Outlook.
- Select Send an email (V2).
- Enter the email address to which you want the email report sent.
- Enter the subject of the email.
- Select Code view.
- Place your cursor in the Body field, and select Add dynamic content.
- Select BodyHtml.
- Select Show advanced options.
- Under Attachments Name -1, select Attachment Name.
- Under Attachments Content, select Attachment Content.
- If necessary, add more attachments.
- If necessary, set the importance level.
- Select Save.
Check if your flow succeeded
To check if your flow succeeded, see the flow's run history:
Go to the Microsoft Power Automate home page.
From the main menu, select My flows.
On the row of the flow you want to investigate, select the more commands icon, and then select Run history.
All flow runs are listed, with information about start time, duration, and status.
For full details about the flow, on My flows, select the flow you want to investigate.
To see why a run failed, select the run start time. The flow appears, and the step of the flow that failed is indicated by a red exclamation point. Expand the failed step to view its details. The Details pane on the right contains information about the failure so that you can troubleshoot it.
Your flow can fail and return a "RequestTimeout" exception if it runs for more than seven minutes.
To fix a timeout issue, make your query more efficient so that it runs faster, or separate it into chunks. Each chunk can run on a different part of the query. For more information, see Query best practices.
The same query might run successfully in Azure Data Explorer, where the time isn't limited and can be changed.
- Results returned to the client are limited to 500,000 records. The overall memory for those records can't exceed 64 MB and a time of seven minutes to run.
- The connector doesn't support the fork and facet operators.
- Flow works best on Microsoft Edge and Google Chrome.
Learn about the Azure Kusto Logic App connector, which is another way to run Kusto queries and commands automatically, as part of a scheduled or triggered task.