将事件中心事件源添加到 Azure 时序见解环境Add an event hub event source to your Azure Time Series Insights environment

本文介绍如何使用 Azure 门户将从 Azure 事件中心读取数据的事件源添加到 Azure 时序见解环境。This article describes how to use the Azure portal to add an event source that reads data from Azure Event Hubs to your Azure Time Series Insights environment.

备注

本文中介绍的步骤对于 Azure 时序见解第 1 代和 Azure 时序见解第 2 代环境都适用。The steps that are described in this article apply both to the Azure Time Series Insights Gen 1 and Azure Time Series Insights Gen 2 environments.

先决条件Prerequisites

将使用者组添加到事件中心Add a consumer group to your event hub

应用程序使用使用者组从 Azure 事件中心提取数据。Applications use consumer groups to pull data from Azure Event Hubs. 若要可靠地从事件中心读取数据,请提供一个仅供此 Azure 时序见解环境使用的专用使用者组。To reliably read data from your event hub, provide a dedicated consumer group that's used only by this Azure Time Series Insights environment.

若要将新使用者组添加到事件中心,请执行以下操作:To add a new consumer group in your event hub:

  1. Azure 门户中,从事件中心命名空间的“概述”窗格中找到并打开事件中心实例。In the Azure portal, locate and open your event hub instance from the Overview pane of your event hub namespace. 选择“实体”>“事件中心”,或在“名称”下查找实例 。Select Entities > Event Hubs or find your instance under Name.

    打开事件中心命名空间Open your event hub namespace

  2. 在事件中心实例中,选择“实体”>“使用者组”。In your event hub instance, select Entities > Consumer groups. 然后,选择“+ 使用者组”,以添加新的使用者组。Then, select + Consumer group to add a new consumer group.

    事件中心 - 添加使用者组Event hub - Add a consumer group

    否则,请选择现有的使用者组并跳到下一部分。Otherwise, select an existing consumer group and skip to the next section.

  3. 在“使用者组”页上,输入一个新的唯一值作为**名称******。On the Consumer groups page, enter a new unique value for Name. 创建新的事件源时,请在 Azure 时序见解环境中使用此相同名称。Use this same name when you create a new event source in the Azure Time Series Insights environment.

  4. 选择“创建”。Select Create.

添加新的事件源Add a new event source

  1. 登录到 Azure 门户Sign in to the Azure portal.

  2. 查找现有的 Azure 时序见解环境。Locate your existing Azure Time Series Insights environment. 在左侧菜单中选择“所有资源”,然后选择 Azure 时序见解环境。In the left menu, select All resources, and then select your Azure Time Series Insights environment.

  3. 选择“事件源”,然后选择“添加”按钮 。Select Event Sources, and then select Add.

    在“事件源”下选择“添加”按钮Under Event Sources, select the Add button

  4. 输入一个值作为特定于此 Azure 时序见解环境的“事件源名称”,如 Contoso-TSI-Gen 1-Event-Hub-ESEnter a value for Event source name that is unique to this Azure Time Series Insights environment, such as Contoso-TSI-Gen 1-Event-Hub-ES.

  5. 对于“源”,选择“事件中心”********。For Source, select Event Hub.

  6. 选择适当的值作为“导入”选项****:Select the appropriate values for Import option:

    • 如果在其中一个订阅中有现有的事件中心,请选择“从可用订阅使用事件中心”****。If you have an existing event hub in one of your subscriptions, select Use Event Hub from available subscriptions. 此选项是最简单的方法。This option is the easiest approach.

      选择“事件源导入”选项Select an Event Source import option

    • 下表介绍的属性是“通过可用订阅使用事件中心”**** 选项所需的:The following table describes the required properties for the Use Event Hub from available subscriptions option:

      订阅和事件中心详细信息Subscription and event hub details

      属性Property 说明Description
      订阅Subscription 所需的事件中心实例和命名空间所属的订阅。The subscription the desired event hub instance and namespace belongs to.
      事件中心命名空间Event Hub namespace 所需的事件中心实例所属的事件中心命名空间。The event hub namespace the desired event hub instance belongs to.
      事件中心名称Event Hub name 所需的事件中心实例的名称。The name of the desired event hub instance.
      事件中心策略值Event Hub policy value 选择所需的共享访问策略。Select the desired shared access policy. 可以在事件中心的“配置”选项卡上创建共享访问策略。每个共享访问策略具有名称、所设权限以及访问密钥。You can create the shared access policy on the event hub Configure tab. Each shared access policy has a name, permissions that you set, and access keys. 事件源的共享访问策略必须** 具有“读取”**** 权限。The shared access policy for your event source must have read permissions.
      事件中心策略密钥Event Hub policy key 从所选的事件中心策略值预填充。Pre-populated from the selected Event Hub policy value.
    • 如果事件中心在订阅外部,或者你希望选择高级选项,请选择“手动提供事件中心设置”****。If the event hub is external to your subscriptions or if you want to select advanced options, select Provide Event Hub settings manually.

      下表介绍“手动提供事件中心设置”选项**** 所需的属性:The following table describes the required properties for the Provide Event Hub settings manually option:

      属性Property 描述Description
      订阅 IDSubscription ID 所需的事件中心实例和命名空间所属的订阅。The subscription the desired event hub instance and namespace belongs to.
      资源组Resource group 所需的事件中心实例和命名空间所属的资源组。The resource group the desired event hub instance and namespace belongs to.
      事件中心命名空间Event Hub namespace 所需的事件中心实例所属的事件中心命名空间。The event hub namespace the desired event hub instance belongs to.
      事件中心名称Event Hub name 所需的事件中心实例的名称。The name of the desired event hub instance.
      事件中心策略值Event Hub policy value 选择所需的共享访问策略。Select the desired shared access policy. 可以在事件中心的“配置”选项卡上创建共享访问策略。每个共享访问策略具有名称、所设权限以及访问密钥。You can create the shared access policy on the event hub Configure tab. Each shared access policy has a name, permissions that you set, and access keys. 事件源的共享访问策略必须** 具有“读取”**** 权限。The shared access policy for your event source must have read permissions.
      事件中心策略密钥Event Hub policy key 用于对服务总线命名空间的访问权限进行身份验证的共享访问密钥。The shared access key that's used to authenticate access to the Service Bus namespace. 在此处输入主密钥或辅助密钥。Enter the primary or secondary key here.
    • 这两个选项共享以下配置选项:Both options share the following configuration options:

      属性Property 描述Description
      事件中心使用者组Event Hub consumer group 从事件中心读取事件的使用者组。The consumer group that reads events from the event hub. 强烈建议为事件源使用专用的使用者组。We highly recommend that you use a dedicated consumer group for your event source.
      事件序列化格式Event serialization format 目前,JSON 是唯一可用的序列化格式。Currently, JSON is the only available serialization format. 事件消息必须采用此格式,否则将无法读取任何数据。Event messages must be in this format or data can't be read.
      时间戳属性名称Timestamp property name 若要确定此值,需要了解发送到事件中心的消息数据的消息格式。To determine this value, you need to understand the message format of the message data that's sent to the event hub. 此值是**** 消息数据中你想要用作事件时间戳的特定事件属性的“名称”。This value is the name of the specific event property in the message data that you want to use as the event timestamp. 该值区分大小写。The value is case-sensitive. 如果留空,则事件源中的“事件排队时间”**** 将用作事件时间戳。If left blank, the event enqueue time in the event source is used as the event timestamp.
  7. 添加已添加到事件中心的专用 Azure 时序见解使用者组名称。Add the dedicated Azure Time Series Insights consumer group name that you added to your event hub.

  8. 选择“创建”。Select Create.

    创建事件源以后,Azure 时序见解就会自动开始将数据流式传输到环境中。After the event source is created, Azure Time Series Insights automatically begins streaming data to your environment.

后续步骤Next steps