Muokkaa

Jaa


Azure Data Explorer connector for Microsoft Power Automate

Important

This connector can be used in Real-Time Intelligence in Microsoft Fabric. Use the instructions in this article with the following exceptions:

The Azure Data Explorer connector for Power Automate (previously Microsoft Flow) enables you to orchestrate and schedule flows, send notifications, and alerts, as part of a scheduled or triggered task.

You can:

  • Send notifications and alerts based on query results, such as when thresholds exceed certain limits.
  • Send regular, such as daily or weekly, reports containing tables and charts.
  • Schedule regular jobs using management commands on clusters. For example, copy data from one table to another using the .set-or-append command.
  • Export and import data between Azure Data Explorer and other databases.

For more information, see Azure Data Explorer Power Automate connector usage examples.

Note

In order for a Power Automate connector to access a network protected cluster, you must add the outbound IP addresses associated with the region of your connector to the firewall allowlist. For more information, see Manage public access to your Azure Data Explorer cluster.

Create a new flow using the Azure Data Explorer connector

To use the connector, you must first add a trigger. You can define a trigger based on a recurring time period, or as a response to a previous flow action.

  1. Sign in to Power Automate.

  2. Create a new flow, or, from the Power Automate home page, select the My flows > + New flow.

    Screenshot of the Power Automate home page, showing My flows and New highlighted.

  3. Select Scheduled cloud flow.

    Screenshot of New dialog box, showing Scheduled from blank highlighted.

  4. In Build a scheduled cloud flow, enter the required information.

    Screenshot of Build a scheduled flow page, showing Flow name options highlighted.

  5. Select Create > + New step.

  6. In the search box, enter Kusto or Azure Data Explorer, and select Azure Data Explorer.

    Screenshot of Choose an operation window, showing the search box and Azure Data Explorer highlighted.

  7. Select an action from the list. For an explanation of each action and how to configure them, see Flow actions.

    Important

    You must have a valid Azure Data Explorer connection for your flow to run. For information about creating a connection, see Create an Azure Data Explorer connection in Power Automate.

    Screenshot of the Choose an action list, showing the list of actions highlighted.

Flow actions

When you select the Azure Data Explorer connector, you can choose one of the following actions to add to your flow:

This section describes the capabilities and parameters for each action and provides an example showing how to add an email action to any flow.

Run KQL query

Note

If your query starts with a dot, it's a management command. Use Run async management command.

Use this action to query the specified cluster. The actions that are added afterwards iterate over each line of the results of the query.

If the query takes more than 8 minutes to run, it will fail with a "RequestTimeout" exception. To prevent this issue, optimize your query or divide it into smaller parts. For more information, see Query best practices.

Example

The following flow triggers a query every minute. The query checks the number of records in the table, and then sends an email only if the number of records is greater than 0.

Screenshot of Azure Data Explorer connector, showing the Run KQL query action.

Run KQL query and render a chart

Note

If your query starts with a dot, it's a management command. Use Run management command and render a chart.

Use this action to visualize a KQL query result as a table or chart. For example, use this flow to receive daily reports by email.

If the query takes more than 8 minutes to run, it will fail with a "RequestTimeout" exception. To prevent this issue, optimize your query or divide it into smaller parts. For more information, see Query best practices.

Example

The following flow will present the query results as a timechart.

Screenshot of Azure Data Explorer connector, showing the Run KQL query and render a chart action.

Run async management command

Use this action to run a management command asynchronously, which means it will continue to run in the background. The action returns an ID, state, and status. To check the status and details of an async command, use the .show operations command with the ID returned by this action.

If the async management command takes more than 60 minutes to run, it will fail with a "RequestTimeout" exception.

Example

The following flow triggers an async command to copy 10 records from the 'TransformedSysLogs' table to the 'TargetTable'. Note that the 'async' keyword is required in the query.

Screenshot of Azure Data Explorer connector, showing the Run async management command action.

Run management command and render a chart

Use this action to run a management command and display the result as a chart. The chart options include an HTML table, pie chart, time chart, and bar chart.

If the management command takes more than 8 minutes to run, it will fail with a "RequestTimeout" exception.

Screenshot of Run management command and render a chart in recurrence pane.

Run show management command

This action runs the show management command and returns the result that can be used in the following connectors.

If the management command takes more than 8 minutes to run, it will fail with a "RequestTimeout" exception.

Example

The following flow runs the .show operation command to find the status of an async command using an operation ID returned by an async command execution.

Screenshot of Azure Data Explorer connector, showing the Run show management command action.

Email Kusto query results

You can include a step in any flow to send reports by email, to any email address.

  1. Select + New Step to add a new step to your flow.
  2. In the search box, enter Office 365 and select Office 365 Outlook.
  3. Select Send an email (V2).
  4. Enter the email address to which you want the email report sent.
  5. Enter the subject of the email.
  6. Select Code view.
  7. Place your cursor in the Body field, and select Add dynamic content.
  8. Select BodyHtml. Screenshot of Send an email dialog box, with Body field and BodyHtml highlighted.
  9. Select Show advanced options.
  10. Under Attachments Name -1, select Attachment Name.
  11. Under Attachments Content, select Attachment Content.
  12. If necessary, add more attachments.
  13. If necessary, set the importance level.
  14. Select Save.

Screenshot of Send an email dialog box, with Attachments Name, Attachments Content, and Save highlighted.

Create an Azure Data Explorer connection

To run a flow that contains an Azure Data Explorer connector, you must use a valid Azure Data Explorer connection. You can create and authenticate a new connection from the Power Automate left pane, select Data > Connections or from within the flow, by selecting the Azure Data Explorer connector's menu > Add new connection.

The following steps show how to create a connection from within a flow.

  1. In Run KQL query, select the three dots at the top right of the power automate connector.

    Screenshot of Azure Data Explorer connection, showing the authentication option.

  2. Select Add new connection. When you connect for the first time, you're prompted to sign in to authenticate the connection.

    Screenshot of Azure Data Explorer connection, showing the sign-in option.

Authentication

You can authenticate with user credentials or with a Microsoft Entra application. To authenticate with credentials, select Sign in, and enter your credentials.

To authenticate with a Service Principal:

  1. Select Connect with Service Principal.

  2. Fill out the form with the following information:

    • Connection Name: A descriptive and meaningful name for the new connection. In this example, we've used "MyApplication".
    • Client ID: Your application ID.
    • Client Secret: Your application key.
    • Tenant: The ID of the Microsoft Entra directory in which you created the application.

    Note

    Make sure your application is an Microsoft Entra application and is authorized to run queries on your cluster.

    Screenshot of Azure Data Explorer connection, showing the application authentication dialog box.

    When authentication is complete, verify that your flow uses the new connection.

    Screenshot of the completed application authentication.

    Once the connection is set, the flow runs using the application credentials.

Test the flow

To check if your flow works, check the flow's run history:

  1. Go to the Power Automate home page.

  2. From the main menu, select My flows.

    Screenshot of Power Automate main menu, showing My flows highlighted.

  3. On the row of the flow you want to investigate, select the more commands icon, and then select Run history.

    Screenshot of My flows tab, showing Run history highlighted.

    All flow runs are listed, with information about start time, duration, and status. Screenshot of Run history results page.

    For full details about the flow, on My flows, select the flow you want to investigate.

    Screenshot of Run history full results page.

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.

Screenshot of flow run, showing an error message.

Limitations

  • The maximum number of records per request is 50,000 and the maximum data size per request is 32 MB. These limits can't be changed.
  • Synchronous requests have a timeout of 8 minutes.
  • Asynchronous requests have a timeout of 60 minutes.
  • The connector doesn't support operators that aren't supported by the getschema operator. For example, the fork, facet, and evaluate operators aren't supported.
  • Flows work best on Microsoft Edge and Google Chrome.