Sending Events to an Event Hub
    • Dark
      Light
    • PDF

    Sending Events to an Event Hub

    • Dark
      Light
    • PDF

    Article Summary

    #ServerlessTips - Azure Event Hubs
    Author: Steef-Jan Wiggers Azure MVP

    Event Hubs is a streaming and event ingestion service on the Microsoft Azure Platform capable of receiving and processing millions of events per second. The service will allow you to process and analyze the massive amounts of data produced by your connected devices and applications.

    Once you have an Event Hub namespace and hub provisioned as described in the tips around creating a namespace and adding an Event Hub, you can start using Event Hubs. With programming languages such as C#, Java or Python, you can send and receive events from an Event Hub.

    When you, for instance, want to send events to an Event Hub using C#, you can create an application (event producer) with Visual Studio 2019 or Visual Studio Code. From with the solution you build with one of these Integrated Development Environments (IDE) you add the Azure.Messaging.EventHubs .NET library (Manage NuGet).

    Once you have access to the library in your solution, you can start writing code to send events to an Event Hub. When writing code for sending events, you create what's called an event producer. For the event producer, you will need a connection string and name of the Event Hub. Both are available in the Event Hub Namespace. From shared access policies in the Event Hub namespace, you can retrieve the connection string, and in the overview of the namespace, you can find the Event Hubs.

    Azure Event Hub Tip 5 - Picture 1

    The code above shows a simple implementation of an event producer. When you run the application, you can verify in the Azure Portal that the event hub has received the messages.

    Azure Event Hub Tip 5 - Picture 2

    Note that you either write code to facilitate to streaming of event data to an Event Hub or you configure your service or device to do so.

    Event-hubs-1.png


    Was this article helpful?