Azure Event Hub

This page illustrates how the Cloud Sink object can be used as a producer to send a message to Azure Event Hub using the Kafka protocol.

If you don’t have access to an Azure Event Hub with Kafka support, the Setting Up a Sample Azure Event Hub page describes how to create a new one.

Requirements

To connect to the Azure Event Hub, you need to have:

  • the Connection String for the Event Hub Namespace,

  • this certificate file: cacert.pem. Make sure to use the 'Save link as' option from the context menu!

Cloud Sink Configuration

1 In WebStudio create a new Cloud Sink object.

2 Select the Cloud Sink object and in the Object Lens, open the Configuration property section.

3 Under Kafka Producer Parameters , for the Topic property, enter the name of the Event Hub.

4 Under Global Configuration Properties, enter the following values for the parameters:

  • For the Bootstrap Servers property, enter the name of the Event Hubs Namespace, followed by .servicebus.windows.net:9093.

  • As Security Protocol property, select SASL-SSL.

  • For the SASL Mechanism property, select PLAIN.

  • Set the SASL Username property to $ConnectionString.

  • For the SASL Password property, enter the Connection string from step 8 of the previous section. For example:
    Endpoint=sb://inmationKafkaTest.servicebus.windows.net/; SharedAccessKeyName=RootManageSharedAccessKey; SharedAccessKey=cHJpbWFyeSBvciBzZWNvbmRhcnkga2V5Ow==+

Azure Kafka service is listening to port 9093

5 Move on to the SSL Parameters section.

6 Click Import File for the SSL Certificate Authority property.

7 Select the cacert.pem file for the Azure Event Hub and click Open.

8 Click View to check the certificate details.

9 Click Apply in the Object Lens to save configuration.

Verifying Data Transfer

1 To check that the interface is working, double-click on Cloud Sink object’s Faceplate and enter a string in the Write Value dialog, then click Write to send the message to Azure Event Hub.

2 Now check the Azure Event Hub metric to see that the message has been captured.

Alternatively, you can install the Azure Event Hub Explorer extension for Visual Studio Code and check the result there.

After deleting a Cloud Sink object, some certificates might be left in the corresponding certificate stores. In order to remove old certificates run the following command in a console:

return require("esi-cloud-interface-initializer"):CLEAN()

Executing this command will not affect any certificates currently used by other Cloud Sink objects.

Callback Options

The properties in the Sink object’s Advanced Options > Callback Options property compound allow the implementation of custom functionality using Lua Scripting.
For a general introduction to callbacks, see Using Callback Properties.

  • The Write Callback property can be used to prepare the data or customize the Kafka message, like adding custom Kafka headers.

  • The Success Callback property is called after a successful data transfer, e.g. to trigger a message.

  • With the Error Callback property custom behavior in case of failed data transfers can be implemented.