教程:设置 Azure 时序见解 Gen2 环境Tutorial: Set up an Azure Time Series Insights Gen2 environment

本教程将逐步引导你创建一个 Azure 时序见解 Gen2 即付即用 (PAYG) 环境。This tutorial guides you through the process of creating an Azure Time Series Insights Gen2 pay-as-you-go (PAYG) environment.

在本教程中,你将了解如何执行以下操作:In this tutorial, you learn how to:

  • 创建 Azure 时序见解 Gen2 环境。Create an Azure Time Series Insights Gen2 environment.
  • 将 Azure 时序见解 Gen2 环境连接到 IoT 中心。Connect the Azure Time Series Insights Gen2 environment to an IoT Hub.
  • 运行解决方案加速器示例,以将数据流式传输到 Azure 时序见解 Gen2 环境。Run a solution accelerator sample to stream data into the Azure Time Series Insights Gen2 environment.
  • 对数据进行基本的分析。Perform basic analysis on the data.
  • 定义时序模型类型和层次结构,并将其与实例相关联。Define a Time Series Model type and hierarchy, and associate it with your instances.

注册一个 Azure 订阅(如果还没有)。Sign up for a Azure subscription if you don't already have one.

先决条件Prerequisites

创建 Azure 时序见解 Gen2 环境Create an Azure Time Series Insights Gen2 environment

本部分介绍如何创建 Azure 时序见解 Gen2 环境,并使用 Azure 门户将其连接到由 IoT 解决方案加速器创建的 IoT 中心。This section describes how to create an Azure Time Series Insights Gen2 environment and connect it to the IoT hub created by the IoT Solution Accelerator using the Azure portal.

  1. 使用 Azure 订阅帐户登录到 Azure 门户Sign in to the Azure portal by using your Azure subscription account.

  2. 选择左上角的“+ 创建资源”。Select + Create a resource in the upper left.

  3. 依次选择“物联网”类别、“时序见解” 。Select the Internet of Things category, and then select Time Series Insights.

    选择时序见解环境资源。Select the Time Series Insights environment resource.

  4. 在“创建时序见解环境”窗格的“基本信息”选项卡上,设置以下参数:In the Create Time Series Insights environment pane, on the Basics tab, set the following parameters:

    参数Parameter 操作Action
    环境名称Environment name 输入 Azure 时序见解 Gen2 环境的唯一名称。Enter a unique name for the Azure Time Series Insights Gen2 environment.
    订阅Subscription 输入想要在其中创建 Azure 时序见解 Gen2 环境的订阅。Enter the subscription where you want to create the Azure Time Series Insights Gen2 environment. 最佳做法是使用与设备模拟器创建的其他 IoT 资源相同的订阅。A best practice is to use the same subscription as the rest of the IoT resources that are created by the device simulator.
    资源组Resource group 为 Azure 时序见解 Gen2 环境资源选择现有的资源组或创建新的资源组。Select an existing resource group or create a new resource group for the Azure Time Series Insights Gen2 environment resource. 资源组是 Azure 资源的容器。A resource group is a container for Azure resources. 最佳做法是使用与设备模拟器创建的其他 IoT 资源相同的资源组。A best practice is to use the same resource group as the other IoT resources that are created by the device simulator.
    位置Location 为 Azure 时序见解 Gen2 环境选择数据中心区域。Select a data center region for your Azure Time Series Insights Gen2 environment. 为了避免额外的延迟,最好是在设备模拟器创建的 IoT 中心所在的区域中创建 Azure 时序见解 Gen2 环境。To avoid additional latency, it's best to create your Azure Time Series Insights Gen2 environment in the same region as your IoT hub created by the device simulator.
    Tier 选择 Gen2(L1)。Select Gen2(L1). 这是 Azure 时序见解 Gen2 产品的 SKU。This is the SKU for the Azure Time Series Insights Gen2 product.
    时序 ID 属性名称Time Series ID property name 输入属性名称,需包含唯一标识时序实例的值。Enter a name of a property that contains values that uniquely identify your time series instances. 以后不能更改在“属性名称”框中作为时序 ID 输入的值。The value you enter in the Property name box as Time Series ID cannot be changed later. 在本教程中,请输入“iothub-connection-device-id”。若要详细了解包含复合时序 ID 的时序 ID,请阅读选择时序 ID 的最佳做法For this tutorial, enter iothub-connection-device-id. To learn more about Time Series ID including composite Time Series ID, read Best practices for choosing a Time Series ID.
    存储帐户名称Storage account name 为新存储帐户输入全局唯一名称。Enter a globally unique name for a new storage account.
    存储帐户类型Storage account kind 为新的存储帐户选择存储类型。Select the storage kind for a new storage account. 建议选择 StorageV2We recommend StorageV2
    存储帐户复制Storage account replication 为新的存储帐户选择存储类型。Select the storage kind for a new storage account. 根据你选择的位置,你可以从 LRS、GRS 和 ZRS 中进行选择。Based on your location selection, you can choose from LRS, GRS, and ZRS. 对于本教程,你可选择 LRSFor this tutorial, you can select LRS
    分层命名空间Hierarchical namespace 选择 StorageV2 存储类型后,可以选择此选项。This option is selectable, once you select the storage kind to be StorageV2. 默认禁用此项。By default, it is disabled. 对于本教程,你可将其保留为默认禁用状态For this tutorial, you can leave it in its default disabled state
    启用 Warm 存储Enable warm store 选择“是”启用 Warm 存储。Select Yes to enable warm store. 也可在创建环境后禁用和重新启用此设置。This setting can be disabled and re-enabled after the environment has been created as well.
    日志保留期(以天为单位)Data retention (in days) 选择默认选项 7 天。Choose the default option of 7 days.

    新的 Azure 时序见解环境配置。New Azure Time Series Insights environment configuration. 新的 Azure 时序见解环境配置(续)。New Azure Time Series Insights environment configuration, continued.

  5. 在完成时选择“下一步:事件源”Select Next: Event Source.

    配置环境的时序 ID。Configure Time Series ID for the environment.

  6. 在“事件源”选项卡上,设置以下参数:On the Event Source tab, set the following parameters:

    参数Parameter 操作Action
    创建事件源?Create an event source? 请选择“是”。Select Yes.
    源类型Source type 选择“IoT 中心”。Select IoT Hub.
    名称Name 输入事件源名称的唯一值。Enter a unique value for the event source name.
    选择中心Select a hub 选择“选择现有”。Choose Select existing.
    订阅Subscription 选择曾经用于设备模拟器的订阅。Select the subscription that you used for the device simulator.
    IoT 中心名称IoT Hub name 选择为设备模拟器创建的 IoT 中心名称。Select the IoT hub name you created for the device simulator.
    Iot 中心访问策略IoT Hub access policy 选择“iothubowner”。Select iothubowner.
    IoT 中心使用者组IoT Hub consumer group 选择“新建”,输入唯一名称,然后选择“+ 添加” 。Select New, enter a unique name, and then select + Add. 在 Azure 时序见解 Gen2 中,使用者组必须是唯一值。The consumer group must be a unique value in Azure Time Series Insights Gen2.
    启动选项Start options 选择“立即开始”。Select Beginning now.
    时间戳属性Timestamp property 此值用于标识传入遥测数据中的 时间戳 属性。This value is used to identify the Timestamp property in your incoming telemetry data. 在本教程中,请将此框留空。For this tutorial, leave this box empty. 此模拟器使用 IoT 中心的传入时间戳,Azure 时序见解 Gen2 默认使用该时间戳。This simulator uses the incoming timestamp from IoT Hub, which Azure Time Series Insights Gen2 defaults to.

    将创建的 IoT 中心配置为事件源

  7. 选择“查看 + 创建” 。Select Review + Create.

    包含“创建”按钮的“查看 + 创建”页

    你可以查看部署的状态:You can review the status of your deployment:

    指出部署已完成的通知。Notification that deployment is complete.

  8. 展开部署详细信息。Expand deployment details.

流式传输数据Stream data

现已部署了 Azure 时序见解 Gen2 环境,请流式传输数据以进行分析。Now that you've deployed your Azure Time Series Insights Gen2 environment, begin streaming data for analysis.

  1. 解决方案加速器部署完成后,你会获得一个 URL。You will be given a URL once the solution accelerator deployment is complete.

  2. 单击该 URL 以启动设备模拟。Click on the URL to launch the device simulation.

  3. 选择“+ 新建模拟” 。Select + New simulation.

    1. 在“模拟设置”页加载后,输入所需的参数。After the Simulation setup page loads, enter the required parameters.

      参数Parameter 操作Action
      名称Name 为模拟器输入唯一名称。Enter a unique name for a simulator.
      说明Description 输入定义。Enter a definition.
      模拟持续时间Simulation duration 设置为“无限期运行”。Set to Run indefinitely.
      设备型号Device model 单击 +“添加设备类型”Click + Add a device type
      名称:输入“电梯”。Name: Enter Elevator.
      数量:输入 3Amount: Enter 3.
      保留其余默认值Leave the remaining default values
      目标 IoT 中心Target IoT Hub 设置为“使用预配的 IoT 中心”。Set to Use pre-provisioned IoT Hub.

      配置参数和启动。Configure parameters and launch.

    2. 选择“开始模拟”。Select Start simulation. 在设备模拟仪表板中,将显示“活动设备数”和“总消息数” 。In the device simulation dashboard, Active devices and Total messages are displayed.

      Azure IoT 模拟仪表板。Azure IoT simulation dashboard.

分析数据Analyze data

在此部分,使用 Azure 时序见解 Gen2 资源管理器对时序数据进行基本的分析。In this section, you perform basic analytics on your time series data by using the Azure Time Series Insights Gen2 Explorer.

  1. Azure 门户中的资源页上选择相应的 URL,转到 Azure 时序见解 Gen2 资源管理器。Go to your Azure Time Series Insights Gen2 Explorer by selecting the URL from the resource page in the Azure portal.

    Azure 时序见解 Gen2 资源管理器 URL。The Azure Time Series Insights Gen2 Explorer URL.

  2. 在 Azure 时序见解 Gen2 资源管理器中,将显示横跨屏幕顶部的一个栏。In the Azure Time Series Insights Gen2 Explorer, a bar spanning the top of the screen will appear. 这是可用性选取器。This is your availability picker. 确保至少选择了两个 2m,并在需要时通过选中选取器控点并将其向左和向右拖动来扩展期限。Ensure that you have at least two 2 m selected, and if needed, expand the time frame by selecting and dragging the picker handles to the left and right.

  3. 时序实例 将显示在左侧。Time Series Instances will be displayed on the left-hand side.

    无父级实例的列表。List of unparented instances.

  4. 选择第一个时序实例。Select the first-time series instance. 然后选择“显示温度”。Then, select Show temperature.

    所选的时序实例,带有的菜单命令可用于显示平均温度。Selected time series instance with menu command to show average temperature.

    此时会显示时序图。A time series chart appears. 将“间隔”更改为 30s 。Change the Interval to 30s.

  5. 重复上一步骤和其他两个时序实例,以便查看全部三个时序实例,如以下图表所示:Repeat the previous step with the other two time series instances so that you're viewing all three, as shown in this chart:

    所有时序的图表。Chart for all time series.

  6. 选择右上角的时间跨度选取器。Select the time span picker in the upper right corner. 你可以在此处选择特定的开始时间和结束时间(最小可选择毫秒),或从预先配置的选项中进行选择(例如,近 30 分钟)。Here you can select specific start and end times down to the millisecond, or choose from pre-configured options such as Last 30 minutes. 也可以更改默认时区。You can also change the default time zone.

    将时间范围设置为近 30 分钟。Set the time range to the last 30 minute.

    解决方案加速器的“过去 30 分钟”进度现在显示在 Azure 时序见解 Gen2 资源管理器中。The solution accelerator's progress over the Last 30 minutes is now displayed in the Azure Time Series Insights Gen2 Explorer.

定义并应用模型Define and apply a model

在本部分,你将应用一个模型来构造数据。In this section, you apply a model to structure your data. 若要完成该模型,需要定义类型、层次结构和实例。To complete the model, you define types, hierarchies, and instances. 若要详细了解数据建模,请阅读时序模型To learn more about data modeling, read Time Series Model.

  1. 在资源管理器中选择“模型”选项卡:In the Explorer, select the Model tab:

    查看资源管理器中的“模型”选项卡。View the Model tab in the Explorer.

    在“类型”选项卡中,选择“+ 添加” 。In the Types tab, select + Add.

  2. 输入以下参数:Enter the following parameters:

    参数Parameter 操作Action
    名称Name 输入“电梯”Enter Elevator
    说明Description 输入“这是电梯的类型定义”Enter This is a type definition for Elevator
  3. 接下来,选择“变量”选项卡。Next, select the Variables tab.

    1. 选择“+ 添加变量”并为电梯类型的第一个变量填写以下值。Select + Add Variable and fill in the following values for the first variable of the Elevator type. 总共创作三个变量。You will author three variables in total.

      参数Parameter 操作Action
      名称Name 输入“平均温度”。Enter Avg Temperature.
      种类Kind 选择“数值”Select Numeric
      Value 从预设中选择:选择“温度(双精度型)”。Select from preset: Select temperature (Double).
      注意:在 Azure 时序见解 Gen2 开始接收事件之后,可能需要等待几分钟才会自动填充“值”。Note: It might take a few minutes for Value to be automatically populated after Azure Time Series Insights Gen2 starts receiving events.
      聚合操作Aggregation Operation 展开“高级选项”。Expand Advanced Options.
      选择“AVG”。Select AVG.
    2. 选择“应用”。Select Apply. 然后,再次选择“+ 添加变量”,并设置以下值:Then, + Add Variable again, and set the following values:

      参数Parameter 操作Action
      名称Name 输入“平均振动”。Enter Avg Vibration.
      种类Kind 选择“数值”Select Numeric
      Value 从预设中选择:选择“振动(双精度)”。Select from preset: Select vibration (Double).
      注意:在 Azure 时序见解 Gen2 开始接收事件之后,可能需要等待几分钟才会自动填充“值”。Note: It might take a few minutes for Value to be automatically populated after Azure Time Series Insights Gen2 starts receiving events.
      聚合操作Aggregation Operation 展开“高级选项”。Expand Advanced Options.
      选择“AVG”。Select AVG.
    3. 选择“应用”。Select Apply. 然后,再次选择“+ 添加变量”,并为第三个和最后一个变量设置以下值:Then, + Add Variable again, and set the following values for the third and final variable:

      参数Parameter 操作Action
      名称Name 输入“楼层”。Enter Floor.
      种类Kind 选择“分类”Select Categorical
      Value 从预设中选择:选择“楼层(双精度)”。Select from preset: Select Floor (Double).
      注意:在 Azure 时序见解 Gen2 开始接收事件之后,可能需要等待几分钟才会自动填充“值”。Note: It might take a few minutes for Value to be automatically populated after Azure Time Series Insights Gen2 starts receiving events.
      类别Categories 标记 - Label - Values
      较低:1、2、3、4Lower: 1,2,3,4
      中层:5、6、7、8、9Middle: 5,6,7,8,9
      较高:10、11、12、13、14、15Upper: 10,11,12,13,14,15
      默认类别Default Category 输入“未知”Enter Unknown

      添加类型变量。Add type variables.

    4. 选择“应用”。Select Apply.

    5. 选择“保存”。Select Save. 此时将创建并显示三个变量。Three variables are created and displayed.

      添加类型后,可在“模型”视图中查看它。After adding the type, review it in the Model view.

  4. 选择“层次结构”选项卡。然后选择“+ 添加”。Select the Hierarchies tab. Then, select + Add.

    1. 在“编辑层次结构”窗格中,设置以下参数:In the Edit Hierarchy pane, set the following parameters:

      参数Parameter 操作Action
      名称Name 输入“位置层次结构”。Enter Location Hierarchy.
      级别Levels 输入“国家/地区”作为第一级的名称Enter Country as the name of the first level
      选择“+ 添加级别”Select + Add Level
      输入“城市”作为第二级,然后选择“+ 添加级别”Enter City for the second level, then select + Add Level
      输入“建筑”作为第三级和最后一个级别的名称Enter Building as the name of the third and final level
    2. 选择“保存”。Select Save.

      在“模型”视图中显示新的层次结构。Display your new hierarchy in the Model view.

  5. 导航到“实例”。Navigate to Instances.

    1. 在最右侧的“操作”下,选择铅笔图标以编辑具有以下值的第一个实例:Under Actions on the far right, and select the pencil icon to edit the first instance with the following values:

      参数Parameter 操作Action
      类型Type 选择“电梯”。Select Elevator.
      名称Name 输入“电梯 1”Enter Elevator 1
      说明Description 输入“电梯 1 的实例”Enter Instance for Elevator 1
    2. 导航到“实例字段”并输入以下值:Navigate to Instance Fields and enter the following values:

      参数Parameter 操作Action
      层次结构Hierarchies 选择“位置层次结构”Select Location Hierarchy
      国家/地区Country 输入“美国”Enter USA
      城市City 输入“西雅图”Enter Seattle
      建筑物Building 输入“太空针塔”Enter Space Needle
    3. 选择“保存”。Select Save.

  6. 使用以下值重复上一步骤和其他两个实例:Repeat the previous step with the other two instances while using the following values:

    对于电梯 2:For Elevator 2:

    参数Parameter 操作Action
    类型Type 选择“电梯”。Select Elevator.
    名称Name 输入“电梯 2”Enter Elevator 2
    说明Description 输入“电梯 2 的实例”Enter Instance for Elevator 2
    层次结构Hierarchies 选择“位置层次结构”Select Location Hierarchy
    国家/地区Country 输入“美国”Enter USA
    城市City 输入“西雅图”Enter Seattle
    建筑物Building 输入“太平洋科学中心”Enter Pacific Science Center

    对于电梯 3:For Elevator 3:

    参数Parameter 操作Action
    类型Type 选择“电梯”。Select Elevator.
    名称Name 输入“电梯 3”Enter Elevator 3
    说明Description 输入“电梯 3 的实例”Enter Instance for Elevator 3
    层次结构Hierarchies 选择“位置层次结构”Select Location Hierarchy
    国家/地区Country 输入“美国”Enter USA
    城市City 输入“纽约”Enter New York
    建筑物Building 输入“帝国大厦”Enter Empire State Building

    查看已更新的实例。View the updated instances.

  7. 导航回到“分析”选项卡以查看图表窗格。Navigate back to the Analyze tab to view the charting pane. 在“位置层次结构”下展开所有层次结构级别,显示时序实例:Under Location Hierarchy, expand all hierarchy levels to display the time series instances:

    在图表视图中查看所有层次结构。View all hierarchies in chart view.

  8. 在“太平洋科学中心”下选择时序实例“电梯 2”,然后选择“显示平均温度” 。Under Pacific Science Center, select the Time Series Instance Elevator 2, and then select Show Average Temperature.

  9. 对于同一实例“电梯 2”,选择“显示楼层”。For the same instance, Elevator 2, select Show Floor.

    借助分类变量,可以确定电梯在较高、较低和中层楼层耗费的时间。With your categorical variable, you can determine how much time the elevator spent on the upper, lower, and middle floors.

    使用层次结构和数据可视化电梯 2。Visualize Elevator 2 with hierarchy and data.

清理资源Clean up resources

现在你已完成本教程,请清除已创建的资源:Now that you've completed the tutorial, clean up the resources you created:

  1. Azure 门户的左侧菜单中,选择“所有资源”,找到“Azure 时序见解 Gen2”资源组。From the left menu in the Azure portal, select All resources, locate your Azure Time Series Insights Gen2 resource group.
  2. 通过选择“删除”来删除整个资源组(以及其中包含的所有资源),或者单独删除每个资源。Either delete the entire resource group (and all resources contained within it) by selecting Delete or remove each resource individually.

后续步骤Next steps

在本教程中,你了解了如何执行以下操作:In this tutorial, you learned how to:

  • 创建 Azure 时序见解 Gen2 PAYG 环境。Create an Azure Time Series Insights Gen2 PAYG environment.
  • 将 Azure 时序见解 Gen2 环境连接到 IoT 中心。Connect the Azure Time Series Insights Gen2 environment to an iot hub.
  • 运行解决方案加速器示例,以将数据流式传输到 Azure 时序见解 Gen2 环境。Run a solution accelerator sample to stream data to the Azure Time Series Insights Gen2 environment.
  • 对数据进行基本的分析。Perform a basic analysis of the data.
  • 定义时序模型类型和层次结构,并将其与实例相关联。Define a Time Series Model type and hierarchy, and associate them with your instances.

知道如何创建自己的 Azure 时序见解 Gen2 环境后,现在来详细了解 Azure 时序见解 Gen2 的关键概念。Now that you know how to create your own Azure Time Series Insights Gen2 environment, learn more about the key concepts in Azure Time Series Insights Gen2.

了解 Azure 时序见解 Gen2 引入:Read about Azure Time Series Insights Gen2 ingestion:

了解 Azure 时序见解 Gen2 存储:Read about Azure Time Series Insights Gen2 storage:

详细了解时序模型:Learn more about Time Series Models:

详细了解如何将环境连接到 Power BI:Learn more about connecting your environment to Power BI: