Creating an Event Hub

This guide walks you through the process of creating an Azure Event Hub, a fundamental component for building real-time data streaming applications. Event Hubs are highly scalable data streaming platforms and event ingestion services.

Prerequisites

Methods for Creating an Event Hub

You can create an Event Hub using several methods:

1. Using the Azure Portal

The Azure portal provides a user-friendly graphical interface for managing your Azure resources.

1

Navigate to your Event Hubs namespace in the Azure portal.

2

In the Event Hubs namespace menu, under "Event Hubs," select "Event hubs."

3

Click the "+ Event Hub" button at the top of the list.

4

Enter a name for your event hub in the "Name" field. Names must be unique within the namespace.

5

Configure the following settings:

  • Partition count: The number of partitions for the event hub. This determines the parallelism of event ingestion and consumption.
  • Message retention: The duration (in days) for which events are stored in the event hub.
  • Capture: Optionally, enable Capture to automatically send event data to Azure Blob Storage or Azure Data Lake Storage.
6

Click "Create." It may take a few moments for the event hub to be provisioned.

2. Using Azure CLI

The Azure Command-Line Interface (CLI) is a powerful tool for automating Azure resource management.

First, ensure you are logged into your Azure account:

az login

Then, use the following command to create an event hub:

az eventhubs event-create --resource-group <your-resource-group-name> --namespace-name <your-namespace-name> --name <your-event-hub-name> --partition-count <number-of-partitions> --message-retention <retention-in-days>

Replace the placeholders with your specific values.

Example:

az eventhubs event-create --resource-group MyResourceGroup --namespace-name MyEventHubNamespace --name MyDataStream --partition-count 4 --message-retention 7

3. Using Azure PowerShell

Azure PowerShell provides another scripting option for managing your resources.

First, ensure you are connected to your Azure account:

Connect-AzAccount

Then, use the following cmdlet:

New-AzEventHub -ResourceGroupName <your-resource-group-name> -Namespace `
    <your-namespace-name> -EventHubName <your-event-hub-name> -PartitionCount <number-of-partitions> `
    -MessageRetentionInDays <retention-in-days>

Replace the placeholders with your specific values.

Key Considerations

Once created, your event hub is ready to receive data. Refer to the Sending Data section for instructions on how to publish events to it.