Azure Data Studio 的 Kusto (KQL) 扩展(预览版)Kusto (KQL) extension for Azure Data Studio (Preview)

使用 Azure Data Studio 的 Kusto (KQL) 扩展,你可以连接到 Azure 数据资源管理器群集并进行查询。The Kusto (KQL) extension for Azure Data Studio enables you to connect and query to Azure Data Explorer clusters.

用户可以使用包含 IntelliSense 的 Kusto 内核,编写并运行 KQL 查询,以及创作笔记本。Users can write and run KQL queries and author notebooks with the Kusto kernel complete with IntelliSense.

通过在 Azure Data Studio 中启用本机 Kusto (KQL) 体验版,数据工程师、数据科学家和数据分析师可以根据存储在 Azure 数据资源管理器中的大量数据快速观察趋势和异常情况。By enabling the native Kusto (KQL) experience in Azure Data Studio, data engineers, data scientists, and data analysts can quickly observe trends and anomalies against massive amounts of data stored in Azure Data Explorer.

此扩展当前处于预览状态。This extension is currently in preview.

先决条件Prerequisites

如果还没有 Azure 订阅,可以在开始前创建一个免费 Azure 帐户If you don't have an Azure subscription, create a free Azure account before you begin.

还需要以下先决条件:The following prerequisites are also required:

安装 Kusto (KQL) 扩展Install the Kusto (KQL) extension

若要在 Azure Data Studio 中安装 Kusto (KQL) 扩展,请按照以下步骤操作。To install the Kusto (KQL) extension in Azure Data Studio, follow the steps below.

  1. 在 Azure Data Studio 中打开扩展管理器。Open the extensions manager in Azure Data Studio. 可以选择扩展图标,也可以在“视图”菜单中选择“扩展”。You can either select the extensions icon or select Extensions in the View menu.

  2. 在搜索栏中,键入“Kusto”。Type in Kusto in the search bar.

  3. 选择“Kusto (KQL)”扩展并查看其详细信息。Select the Kusto (KQL) extension and view its details.

  4. 选择“安装” 。Select Install.

Kusto 扩展

如何连接到 Azure 数据资源管理器群集How to connect to an Azure Data Explorer cluster

查找 Azure 数据资源管理器群集。Find your Azure Data Explorer cluster

Azure 门户中找到 Azure 数据资源管理器群集,然后找到该群集的 URI。Find your Azure Data Explorer cluster in the Azure portal, then find the URI for the cluster.

URI

不过,你可以立即开始使用 help.kusto.windows.net 群集。However, you can get started immediately using the help.kusto.windows.net cluster.

在本文中,我们将使用 help.kusto.windows.net 群集中的数据作为示例。For this article, we're using data from the help.kusto.windows.net cluster for samples.

连接详细信息Connection details

若要设置要连接到的 Azure Data Explorer 群集,请按照以下步骤操作:To set up an Azure Data Explorer cluster to connect to, follow the steps below.

  1. 从“连接”窗格选择“新建连接” 。Select New connection from the Connections pane.

  2. 填写“连接详细信息”信息。Fill in the Connection Details information.

    1. 对于“连接类型”,请选择“Kusto”。For Connection type , select Kusto.

    2. 对于“群集”,请输入 Azure 数据资源管理器群集。For Cluster , enter in your Azure Data Explorer cluster.

      备注

      输入群集名称时,请勿包含 https:// 前缀或尾随 /When entering the cluster name, don't include the https:// prefix or a trailing /.

    3. 对于“身份验证类型”,请使用默认值“具有 MFA 支持的通用 Azure Active Directory”。For Authentication Type , use the default - Azure Active Directory - Universal with MFA account.

    4. 对于“帐户”,请使用你的帐户信息。For Account , use your account information.

    5. 对于“数据集”,请使用“默认”。For Database , use Default.

    6. 对于“服务器组”,请使用“默认”。For Server Group , use Default.

      1. 可以使用此字段来组织特定组中的服务器。You can use this field to organize your servers in a specific group.
    7. 对于“名称(可选)”,请留空。For Name (optional) , leave blank.

      1. 可以使用此字段为服务器指定别名。You can use this field to give your server an alias.

    连接详细信息

如何在 Azure Data Studio 中查询 Azure 数据资源管理器数据库How to query an Azure Data Explorer database in Azure Data Studio

设置与 Azure 数据资源管理器群集的连接后,接下来可以使用 Kusto (KQL) 查询数据库。Now that you have set up a connection to your Azure Data Explorer cluster, you can query your database(s) using Kusto (KQL).

若要创建新查询选项卡,可以选择“文件”>“新建查询”(使用 Ctrl + N),也可以双击该数据库,再选择“新建查询”。To create a new query tab, you can either select File > New Query , use Ctrl + N , or right-click the database and select New Query.

打开新的查询选项卡之后,输入 Kusto 查询。Once you have your new query tab open, then enter your Kusto query.

下面是 KQL 查询的一些示例:Here are some samples of KQL queries:

StormEvents
| limit 1000
StormEvents
| where EventType == "Waterspout"

有关编写 KQL 查询的详细信息,请访问编写 Azure 数据资源管理器查询For more information about writing KQL queries, visit Write queries for Azure Data Explorer

查看扩展设置View extension settings

若要更改 Kusto 扩展的设置,请按照以下步骤操作。To change the settings for the Kusto extension, follow the steps below.

  1. 在 Azure Data Studio 中打开扩展管理器。Open the extension manager in Azure Data Studio. 可以选择扩展图标,也可以在“视图”菜单中选择“扩展”。You can either select the extensions icon or select Extensions in the View menu.

  2. 找到 Kusto (KQL) 扩展。Find the Kusto (KQL) extension.

  3. 选择“管理”图标。Select the Manage icon.

  4. 选择“扩展设置”图标。Select the Extension Settings icon.

扩展设置如下所示:The extensions settings look like this:

Kusto (KQL) 扩展设置

SandDance 可视化效果SandDance visualization

SandDance 扩展和 Azure Data Studio 中的 Kusto (KQL) 扩展结合使用时会带来丰富的交互式可视化效果。The SandDance extension with the Kusto (KQL) extension in Azure Data Studio bring rich interactive visualization together. 从 KQL 查询结果集中,选择“可视化工具”按钮,启动 SandDanceFrom the KQL query result set, select the Visualizer button to launch SandDance.

SandDance 可视化效果

已知问题Known issues

详细信息Details 解决方法Workaround
在 Kusto 笔记本中,当代码单元执行中出现错误后,在保存的别名连接中更改数据库连接的操作会停滞In Kusto notebook, Changing a database connection on a saved alias connection is stuck after an error in code cell execution 请关闭再重新打开笔记本,然后使用该数据库连接到适当的群集Close and reopen the Notebook, then connect to the right cluster with the database
在 Kusto 笔记本中,无法在未保存的别名连接上更改数据库连接In Kusto Notebook, changing a database connection on a non-saved alias connection doesn't work 从连接 Viewlet 创建新连接,并使用别名保存它。Create a new connection from Connection Viewlet and save it with an alias. 然后,创建一个新的笔记本并连接到新保存的连接Then create a new notebook and connect to the newly saved connection)
在 Kusto 笔记本中,创建新的 ADX 连接时不会填充数据库下拉列表In Kusto Notebook, the database dropdown isn't populated when creating a new ADX connection 从连接 Viewlet 创建新连接,并使用别名保存它。Create a new connection from Connection Viewlet and save it with an alias. 然后,创建一个新的笔记本并连接到新保存的连接Then create a new notebook and connect to the newly saved connection)

你可以提交功能请求,向产品团队提供反馈。You can file a feature request to provide feedback to the product team.
你可以提交 bug,向产品团队提供反馈。You can file a bug to provide feedback to the product team.

后续步骤Next steps