使用一键式引入将 JSON 数据从本地文件引入到 Azure 数据资源管理器中的现有表Use one-click ingestion to ingest JSON data from a local file to an existing table in Azure Data Explorer

借助一键式引入,可将 JSON、CSV 和其他格式的数据快速引入表中并轻松创建映射结构。One-click ingestion enables you to quickly ingest data in JSON, CSV, and other formats into a table and easily create mapping structures. 数据可以从存储、本地文件或容器引入,可以是一次性引入过程,也可以是持续引入过程。The data can be ingested either from storage, from a local file, or from a container, as a one-time or continuous ingestion process.

本文档介绍如何在特定用例中使用直观的一键式向导将本地文件中的 JSON 数据引入到现有表中 。This document describes using the intuitive one-click wizard in a specific use case to ingest JSON data from a local file into an existing table. 使用稍微改动的同一过程来覆盖各种不同的用例。Use the same process with slight adaptations to cover a variety of different use cases.

有关一键式引入的概述和先决条件列表,请参阅一键式引入For an overview of one-click ingestion and a list of prerequisites, see One-click ingestion. 如需了解数据的不同类型或源,请参阅使用一键式引入将 CSV 数据从容器引入到 Azure 数据资源管理器中的新表For different types or sources of data, see Use one-click ingestion to ingest CSV data from a container to a new table in Azure Data Explorer.

引入新数据Ingest new data

在 Web UI 的左侧菜单中,右键单击“数据库”或“表”,然后选择“引入新数据” 。In the left menu of the Web UI, right-click a database or table and select Ingest new data.

在 Web UI 中选择一键式引入

选择引入类型Select an ingestion type

  1. 在“引入新数据”窗口中,“源”选项卡处于选中状态 。In the Ingest new data window, the Source tab is selected.

  2. 如果“群集”和“数据库”字段未自动填充,请从下拉菜单中选择一个现有群集和数据库名称 。If the Cluster and Database fields aren't automatically filled, select an existing cluster and database name from the drop-down menu.

    1. 若要向群集添加新连接,可选择自动填充的群集名称下面的“添加群集连接”。To add a new connection to a cluster, select Add cluster connection below the auto-populated cluster name.

      引入新数据选项卡 - 添加新的群集连接

    2. 在弹出窗口中,输入要连接的群集的“连接 URI”。In the popup window, enter the Connection URI for the cluster you are connecting.

    3. 输入要用于标识此群集的“显示名称”,然后选择“添加”。Enter a Display Name that you want to use to identify this cluster, and select Add.

      添加群集 URI 和相关描述以在 Azure 数据资源管理器中添加新的群集连接

  3. 如果“表”字段未自动填充,请从下拉菜单中选择一个现有的表名。If the Table field isn't automatically filled, select an existing table name from the drop-down menu.

  4. 在“源类型”下,执行以下步骤:Under Source type, do the following steps:

    1. 选择“从文件”Select from file

    2. 选择“浏览”查找文件(最多 10 个),或将文件拖到字段中。Select Browse to locate up to 10 files, or drag the files into the field. 可以使用蓝色星形来选择架构定义文件。The schema-defining file can be chosen using the blue star.

      从文件进行一键式引入

编辑架构Edit the schema

选择“编辑架构”以查看并编辑表列配置。Select Edit schema to view and edit your table column configuration. 在“架构”选项卡中:In the Schema tab:

添加嵌套的 JSON 数据Add nested JSON data

如果要从与上述所选的主要 JSON 级别不同的嵌套级别中添加列,请执行以下步骤:To add columns from JSON levels that are different than the main Nested levels selected above, do the following steps:

  1. 单击任何列名旁边的箭头,然后选择“新建列”。Click on the arrow next to any column name, and select New column.

    一张屏幕截图,显示在一键式引入过程中用于添加“新建列 - 架构”选项卡的选项 - Azure 数据资源管理器

  2. 输入新的列名,然后从下拉菜单中选择“列类型” 。Enter a new Column Name and select the Column Type from the dropdown menu.

  3. 在“源”下,选择“新建” 。Under Source, select Create new.

    屏幕截图 - 在一键式引入过程中创建新源来添加嵌套的 JSON 数据 - Azure 数据资源管理器

  4. 为此列输入新源,然后单击“确定”。Enter the new source for this column and click OK. 此源可来自任何 JSON 级别。This source can come from any JSON level.

    屏幕截图 - 用于为添加的列命名新的数据源的弹出窗口 - Azure 数据资源管理器一键式引入

  5. 选择“创建”。Select Create. 新列将添加到表的末尾。Your new column will be added at the end of the table.

    屏幕截图 - 在Azure 数据资源管理器中,在一键式引入期间创建新列

编辑表Edit the table

The changes you can make in a table depend on the following parameters:

  • Table type is new or existing
  • Mapping type is new or existing
Table type Mapping type Available adjustments
New table New mapping Change data type, Rename column, New column, Delete column, Update column, Sort ascending, Sort descending
Existing table New mapping New column (on which you can then change data type, rename, and update),
Update column, Sort ascending, Sort descending
Existing mapping Sort ascending, Sort descending

备注

When adding a new column or updating a column, you can change mapping transformations. For more information, see Mapping transformations

备注

  • 对于表格格式,无法映射列两次。For tabular formats, you can’t map a column twice. 若要映射到现有列,请先删除新列。To map to an existing column, first delete the new column.
  • 不能更改已有列类型。You can’t change an existing column type. 如果尝试映射到其他格式的列,结果可能出现空列。If you try to map to a column having a different format, you may end up with empty columns.

Command editor

Above the Editor pane, select the v button to open the editor. In the editor, you can view and copy the automatic commands generated from your inputs.

One click ingestion edit view

开始引入Start ingestion

选择“开始引入”,在创建表和映射后开始引入数据。Select Start ingestion to create a table and mapping and to begin data ingestion.

开始引入

完成数据引入Complete data ingestion

如果数据引入成功完成,则“数据引入已完成”窗口中的所有三个步骤都会带有绿色的对勾标记。In the Data ingestion completed window, all three steps will be marked with green check marks when data ingestion finishes successfully.

一键式数据引入已完成

Explore quick queries and tools

In the tiles below the ingestion progress, explore Quick queries or Tools:

  • Quick queries includes links to the Web UI with example queries.

  • Tools includes links to Undo or Delete new data on the Web UI, which enable you to troubleshoot issues by running the relevant .drop commands.

    备注

    You might lose data when you use .drop commands. Use them carefully. Drop commands will only revert the changes that were made by this ingestion flow (new extents and columns). Nothing else will be dropped.

后续步骤Next steps