您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

Azure 数据资源管理器连接器可实现 (预览版的自动功能) Azure Data Explorer connector to Power Automate (Preview)

Azure 数据资源管理器 flow 连接器允许 Azure 数据资源管理器使用 Microsoft Power 自动功能的流功能。The Azure Data Explorer flow connector allows Azure Data Explorer to use the flow capabilities of Microsoft Power Automate. 可以在计划或触发的任务中自动运行 Kusto 查询和命令。You can run Kusto queries and commands automatically, as part of a scheduled or triggered task.

可以:You can:

  • 发送包含表和图表的每日报告。Send daily reports containing tables and charts.
  • 基于查询结果设置通知。Set notifications based on query results.
  • 在群集上计划控制命令。Schedule control commands on clusters.
  • 在 Azure 数据资源管理器和其他数据库之间导出和导入数据。Export and import data between Azure Data Explorer and other databases.

有关详细信息,请参阅 Azure 数据资源管理器 flow 连接器使用示例For more information, see Azure Data Explorer flow connector usage examples.

登录Sign in

  1. 首次连接时,系统将提示你登录。When you connect for the first time, you're prompted to sign in.

  2. 选择 " 登录",然后输入你的凭据。Select Sign in, and enter your credentials.

Azure 数据资源管理器登录提示的屏幕截图

身份验证Authentication

您可以使用用户凭据进行身份验证,也可以使用 Azure Active Directory (Azure AD) 应用程序进行身份验证。You can authenticate with user credentials, or with an Azure Active Directory (Azure AD) application.

备注

请确保应用程序是 Azure AD 应用程序,并且有权在群集上运行查询。Make sure your application is an Azure AD application, and is authorized to run queries on your cluster.

  1. 在 " 运行控制" 命令和 "可视化结果" 中,选择 flow 连接器右上角的三个点。In Run control command and visualize results, select the three dots at the top right of the flow connector.

    运行控制命令和可视化结果的屏幕截图

  2. 选择 "添加新 > 的连接与服务主体连接"。Select Add new connection > Connect with Service Principal.

    Azure 数据资源管理器登录提示的屏幕截图,带 "连接服务主体" 选项

  3. 输入所需信息:Enter the required information:

    • 连接名称:新连接的描述性名称(有意义)。Connection Name: A descriptive and meaningful name for the new connection.
    • 客户端 ID:应用程序 ID。Client ID: Your application ID.
    • 客户端密码:应用程序密钥。Client Secret: Your application key.
    • 租户:在其中创建应用程序的 Azure AD 目录的 ID。Tenant: The ID of the Azure AD directory in which you created the application.

    "Azure 数据资源管理器应用程序身份验证" 对话框的屏幕截图

身份验证完成后,你将看到你的流使用新添加的连接。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.

查找 Azure Kusto 连接器Find the Azure Kusto connector

若要使用 flow 连接器,需要首先添加触发器。To use the flow 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.

  1. 创建新流,或在 "Microsoft Power 自动" 主页上,选择 "我的流 > + 新建"。Create a new flow, or, from the Microsoft Power Automate home page, select the My flows > + New.

    Microsoft Power 自动主页的屏幕截图,其中的流和新的突出显示

  2. 选择 " 计划--从空白"。Select Scheduled--from blank.

    新对话框的屏幕截图,其中突出显示了 "按计划显示"

  3. 在 " 生成计划的流" 中,输入所需的信息。In Build a scheduled flow, enter the required information.

    "生成计划的流" 页的屏幕截图,其中突出显示了 "流名称" 选项

  4. 选择 "创建 > + 新步骤"。Select Create > + New step.

  5. 在搜索框中,输入 " Kusto",并选择 " Azure 数据资源管理器"。In the search box, enter Kusto, and select Azure Data Explorer.

    选择操作选项的屏幕截图,其中突出显示了 "搜索框和 Azure 数据资源管理器

流操作Flow actions

打开 Azure 数据资源管理器连接器时,可以向流中添加三个可能的操作。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.

Azure 数据资源管理器连接器操作的屏幕截图

运行控制命令和可视化结果Run control command and visualize results

使用此操作运行 控件命令Use this action to run a control command.

  1. 指定群集 URL。Specify the cluster URL. 例如,https://clusterName.eastus.kusto.windows.netFor example, https://clusterName.eastus.kusto.windows.net.
  2. 输入数据库的名称。Enter the name of the database.
  3. 指定 control 命令: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.
  4. 若要通过电子邮件将此操作的结果发送为表格或图表,请指定图表类型。To send the results of this action by email as a table or a chart, specify the chart type. 这可以是:This can be:
    • 一个 HTML 表。An HTML table.
    • 饼图。A pie chart.
    • 时间图表。A time chart.
    • 条形图。A bar chart.

运行控制命令和可视化结果的屏幕截图

重要

在 " 群集名称 " 字段中,输入群集 URL。In the Cluster Name field, enter the cluster URL.

运行查询并列出结果Run query and list results

备注

如果查询以点开头 (这意味着它是一个) 的 控件命令 ,请使用 " 运行控制" 命令并显示结果If your query starts with a dot (meaning that it's a control command), use Run control command and visualize results.

此操作将查询发送到 Kusto 群集。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. 查询将检查数据库中的行数,然后仅当行数大于0时才发送电子邮件。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

备注

如果查询以点开头 (这意味着它是一个) 的 控件命令 ,请使用 " 运行控制" 命令并显示结果If your query starts with a dot (meaning that it's a control command), use Run control command and visualize results.

使用此操作可以将 Kusto 查询结果可视化为表或图表。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.

在此示例中,查询的结果以 HTML 表的形式返回。In this example, the results of the query are returned as an HTML table.

运行查询和可视化结果的屏幕截图

重要

在 " 群集名称 " 字段中,输入群集 URL。In the Cluster Name field, enter the cluster URL.

电子邮件 Kusto 查询结果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. 在搜索框中,输入 office 365 ,然后选择 office 365 OutlookIn the search box, enter Office 365 and select Office 365 Outlook.
  3. 选择“发送电子邮件(V2)”。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. 选择 BodyHtmlSelect BodyHtml. "发送电子邮件" 对话框的屏幕截图,其中突出显示了正文字段和 BodyHtmlScreenshot of Send an email dialog box, with Body field and BodyHtml highlighted
  9. 选择 " 显示高级选项"。Select Show advanced options.
  10. 在 " 附件名称-1" 下,选择 " 附件名称"。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.

"发送电子邮件" 对话框的屏幕截图,其中包含附件名称、附件内容和突出显示的 "保存"

检查流是否成功Check if your flow succeeded

若要检查流是否成功,请查看流的运行历史记录:To check if your flow succeeded, see the flow's run history:

  1. 请参阅 Microsoft Power 自动主页Go to the Microsoft Power Automate home page.

  2. 从主菜单中选择 " 我的流"。From the main menu, select My flows.

    Microsoft Power 自动功能主菜单的屏幕截图,其中突出显示了我的流

  3. 在要调查的流的行上,选择 "更多命令" 图标,然后选择 " 运行历史记录"。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. 运行历史记录结果页的屏幕截图Screenshot of Run history results page

    有关流的完整详细信息,请在 "我的流" 上选择要调查的流。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.

"流错误" 页的屏幕截图

超时异常Timeout exceptions

如果流运行超过7分钟,则流可能失败并返回 "RequestTimeout" 异常。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.

相同的查询可能在 Azure 数据资源管理器中成功运行,这种情况下,时间不受限制并且可以更改。The same query might run successfully in Azure Data Explorer, where the time isn't limited and can be changed.

限制Limitations

  • 返回给客户端的结果限制为500000条记录。Results returned to the client are limited to 500,000 records. 这些记录的总体内存不能超过 64 MB 和运行7分钟的时间。The overall memory for those records can't exceed 64 MB and a time of seven minutes to run.
  • 连接器不支持 分叉 运算符和 facet 运算符。The connector doesn't support the fork and facet operators.
  • 流最适用于 Microsoft Edge 和 Google Chrome。Flow works best on Microsoft Edge and Google Chrome.

后续步骤Next steps

了解 Azure Kusto 逻辑应用连接器,这是在计划或触发的任务中自动运行 Kusto 查询和命令的另一种方法。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.