Help Center/ EventGrid/ User Guide/ Event Subscriptions/ Creating an Event Subscription
Updated on 2023-05-29 GMT+08:00

Creating an Event Subscription

Event subscriptions bind event sources, channels, and targets, and route events of sources to targets based on specified rules.

A subscription can be bound with up to five targets.

Prerequisites

Procedure

  1. Log in to the EG console.
  2. In the navigation pane, choose Event Subscriptions.
  3. Click Create Event Subscription.
  4. Click next to the default subscription name.
  5. Enter a new subscription name and description, and click OK.
  6. Configure an event source.

    1. Click Event Source, as shown in Figure 1.
      Figure 1 Configuring an event source
    2. Select an event source provider.
      • Huawei Cloud: Huawei Cloud service event source
      • Custom: custom event source
    3. Set event source parameters.
      When selecting Huawei Cloud, set the parameters listed in Table 1.
      Table 1 Cloud service event source parameters

      Parameter

      Description

      Event Source

      Select a cloud service event source.

      Event Type

      (Optional) Select a predefined event type.

      Filter Rule

      Enter an event filter rule.

      Only events that match these filter rules will be routed to the associated targets. For more information about filter rules, see Filter Rule Parameters and Example Filter Rules.

      Figure 2 Configuring a cloud service event source
      When selecting Custom, set the parameters listed in Table 2.
      Table 2 Custom event source parameters

      Parameter

      Description

      Channel

      Type

      Two types are available:

      • Existing: Select an existing custom event channel.
      • New: Create an event channel.

      Channel

      • If Type is set to Existing, select an existing custom event channel, for example, channel.
      • If Type is set to New, enter a channel name.

      Description

      Set this parameter only when Type is set to New.

      Describe the custom event channel.

      Event Source

      Type

      Two types are available:

      • Existing: Select an existing custom event source.
      • New: Create an event source.

      Event Source

      • If Type is set to Existing, select a custom event source associated with the custom event channel you specify, for example, channel.
      • If Type is set to New, enter a source name.

      Description

      Set this parameter only when Type is set to New.

      Describe the custom event source.

      Filter Rule

      Enter an event filter rule.

      Only events that match these filter rules will be routed to the associated targets. For more information about filter rules, see Filter Rule Parameters and Example Filter Rules.

      Figure 3 Configuring a custom event source

    4. Click OK.

  7. Configure an event target.

    A subscription can be bound with up to five targets.

    1. Click Event Target, as shown in Figure 4.
      Figure 4 Configuring an event target
    2. Select an event target provider.
      • Huawei Cloud: Huawei Cloud service event target
      • Custom: custom event target
    3. Set event target parameters.
      When selecting Huawei Cloud, set the following parameters.
      • Event Target: Select an event target.

        If you set Event Target to FunctionGraph (function computing):

        • Function: Select the function to trigger. If no function is available, create one by referring to section "Creating a Function".
        • Version/Alias: Choose to specify a version or alias.
        • Version: Select a version of the function. By default, latest is selected.
        • Alias: Select an alias of the function.

        If you set Event Target to Distributed Message Service (DMS) for Kafka:

        • Connection: Select a DMS for Kafka connection.
        • Topic: Select a message topic.
        • Enable: Whether to enable the message key function.
        • Transform Type: Defines how message keys are used. There are two options:
          • Variables: Keys are variable values from CloudEvents-compliant events.
          • Constants: Keys are specified constants. All messages will be sent to the same partition.

          For more information about the transform types, see Event Content Transformation.

        Rule:

      • Transform Type: EG transforms CloudEvents-compliant events for targets. The following three types are supported:
        • Pass-through: Directly route CloudEvents-compliant events to the target.
        • Variables: Route variables in CloudEvents-compliant events to the target.
        • Constants: Route constants in events to the target.

        For more information about the transform types, see Event Content Transformation.

      Figure 5 Configuring a Huawei Cloud service event target
      When selecting Custom, set the following parameters.
      • URL: Enter the URL of an event target.
      • Connection: Select a custom or the default connection.
      • Transform Type: EG transforms CloudEvents-compliant events for targets. The following three types are supported:
        • Pass-through: Directly route CloudEvents-compliant events to the target.
        • Variables: Route variables in CloudEvents-compliant events to the target.
        • Constants: Route constants in events to the target.

        For more information about the transform types, see Event Content Transformation.

      Figure 6 Configuring a custom event target
    4. Click OK.

  8. Click Save.

    The subscription is enabled by default once created.