Creating an Azure Event Hub
This guide walks you through the process of creating an Azure Event Hub using the Azure portal. Event Hubs are a highly scalable data streaming platform and event ingestion service that can serve multiple purposes.
Prerequisites
- An active Azure subscription. If you don't have one, you can create a free account.
- An Azure Event Hubs namespace. If you don't have one, you'll need to create it first. You can find instructions here.
Steps to Create an Event Hub
1. Navigate to Your Event Hubs Namespace
- Sign in to the Azure portal.
- In the search bar at the top, type "Event Hubs" and select "Event Hubs Namespaces".
- Select the namespace in which you want to create your Event Hub.
2. Create a New Event Hub
- In your Event Hubs namespace page, under the "Settings" section, click on "Event Hubs".
- Click the + Event Hub button at the top of the Event Hubs list.
3. Configure Event Hub Settings
A "Create Event Hub" panel will appear. Fill in the following details:
- Name: Enter a unique name for your Event Hub. This name must be unique within the namespace. For example,
my-app-events. - Partition Count: This setting determines the number of partitions for the Event Hub. Higher partition counts allow for greater parallelism in consuming events. Choose a number that aligns with your expected throughput and number of consumers. A common starting point is 2 or 4.
- Message Retention: Specify how long events should be retained in the Event Hub. The default is 1 day. You can increase this up to 7 days for standard Tiers.
- Capture (Optional): You can enable Event Hubs Capture to automatically save events to an Azure Blob Storage account or Azure Data Lake Storage Gen2. This is useful for archiving and batch processing. If you enable it, you'll need to specify your storage account and container.
After filling in the details, click Create.
4. Verification
Once the creation process is complete, you will see a notification in the Azure portal. Your new Event Hub will appear in the list of Event Hubs for your namespace.
You can click on the name of your newly created Event Hub to view its properties, including its connection strings, metrics, and other settings.
Example: Creating an Event Hub using Azure CLI
You can also create an Event Hub using the Azure Command-Line Interface (CLI) for automation.
First, create the Event Hub:
az eventhubs event-hubs create --name <event-hub-name> --namespace-name <namespace-name> --resource-group <resource-group-name> --partition-count <number-of-partitions> --message-retention-in-days <retention-days>
Example:
az eventhubs event-hubs create --name my-app-events --namespace-name my-eventhub-namespace --resource-group my-resource-group --partition-count 4 --message-retention-in-days 3
To confirm creation:
az eventhubs event-hubs list --namespace-name <namespace-name> --resource-group <resource-group-name>
Next Steps
Now that you've created an Event Hub, you'll likely want to:
- Obtain connection strings to send and receive data.
- Configure consumers to read data from your Event Hub.
- Set up monitoring to track Event Hub performance.