github.com/argoproj/argo-events@v1.9.1/docs/sensors/triggers/azure-event-hubs.md (about)

     1  # Azure Event Hubs
     2  
     3  Azure Event Hubs Trigger allows a sensor to publish events to [Azure Event Hubs](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-about). Argo Events integrates with Azure Event Hubs to stream data from an `EventSource`
     4  
     5  **NOTE:** Parametrization for `fqdn` and `hubName` values are not yet supported.
     6  
     7  ## Specification
     8  
     9  The Azure Event Hubs trigger specification is available [here](https://github.com/argoproj/argo-events/blob/master/api/sensor.md#azureeventhubstrigger).
    10  
    11  ## Send an Event to Azure Event Hubs
    12  
    13  1. Make sure to have the eventbus deployed in the namespace.
    14  
    15  1. [Create an event hub](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-create).
    16  
    17  1. Make sure that the Shared Access Key used to connect to Azure Event Hubs has the `Send` policy.
    18  
    19  1. Get the `Primary Key` of the Shared Access Policy, the `Name` of the Shared Access Policy, the `Hub Name`, and the `FQDN` of the Azure Event Hubs Namespace.
    20  
    21  1. Create a secret called `azure-event-hubs-secret` as follows:
    22  
    23      **NOTE: `sharedAccessKey` refers to the `Primary Key` and `sharedAccessKeyName` refers to the Name of the Shared Access Policy.**
    24  
    25          apiVersion: v1
    26          kind: Secret
    27          metadata:
    28            name: azure-event-hubs-secret
    29          type: Opaque
    30          data:
    31            sharedAccessKey: <base64-shared-access-key>
    32            sharedAccessKeyName: <base64-shared-access-key-name>
    33  
    34  1. Let's set up a webhook event-source to process incoming requests.
    35  
    36          kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/event-sources/webhook.yaml
    37  
    38  1. Create the sensor with the following template. Replace the necessary values for `fqdn` and `hubName`:
    39  
    40          apiVersion: argoproj.io/v1alpha1
    41          kind: Sensor
    42          metadata:
    43            name: azure-events-hub
    44          spec:
    45            dependencies:
    46              - name: test-dep
    47                eventSourceName: webhook
    48                eventName: example
    49            triggers:
    50              - template:
    51                name: azure-eventhubs-trigger
    52                azureEventHubs:
    53                # FQDN of the EventsHub namespace you created
    54                # More info at https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-get-connection-string
    55                  fqdn: eventhubs_fqdn
    56                  sharedAccessKeyName:
    57                    name: azure-event-hubs-secret
    58                    key: sharedAccessKeyName
    59                  sharedAccessKey:
    60                    name: azure-event-hubs-secret
    61                    key: sharedAccessKey
    62                  # Event Hub path/name
    63                  hubName: hub_name
    64                  payload:
    65                    - src:
    66                        dependencyName: test-dep
    67                        dataKey: body.message
    68                      dest: message
    69  
    70  1. The Event needs a body. In order to construct a messaged based on your event data, the Azure Event Hubs sensor has the `payload` field as part of the trigger.
    71  
    72      The `payload` contains the list of `src` which refers to the source events and `dest` which refers to destination key within the resulting request payload.
    73  
    74     The `payload` declared above will generate a message body like below,
    75  
    76          {
    77              "message": "some message here" // name/key of the object
    78          }
    79  
    80  1. Let's expose the webhook event-source pod using `port-forward` so that we can make a request to it.
    81    
    82          kubectl -n argo-events port-forward <name-of-event-source-pod> 12000:12000   
    83  
    84  1. Use either Curl or Postman to send a post request to the `http://localhost:12000/example`.
    85  
    86          curl -d '{"message":"ok"}' -H "Content-Type: application/json" -X POST http://localhost:12000/example
    87  
    88  1. Verify Events have been in ingested in Azure Events Hub by creating a [listener app](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-go-get-started-send#receive-events) or following other [code samples](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-samples). You can optionally create an [Azure Event Hubs Event Source](https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/event-sources/azure-event-hubs-sensor.yaml).