Create an Event Hub in Azure
This tutorial will guide 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.
Prerequisites
- An Azure subscription. If you don't have one, create a free account.
- Permissions to create resources in your Azure subscription.
Steps to Create an Event Hub
-
Sign in to the Azure Portal
Open your web browser and navigate to https://portal.azure.com/. Sign in with your Azure account credentials.
-
Navigate to Event Hubs
In the Azure portal search bar, type "Event Hubs" and select "Event Hubs" from the search results. Alternatively, you can find it under "All services" -> "Integration" -> "Event Hubs".
-
Create an Event Hubs Namespace
Event Hubs are contained within namespaces. You need to create a namespace before you can create an Event Hub. Click the "+ Create" button.
-
Configure Namespace Settings
On the "Create namespace" page, fill in the following details:
- Subscription: Select the Azure subscription you want to use.
- Resource group: Choose an existing resource group or create a new one by clicking "Create new".
- Namespace name: Enter a unique name for your Event Hubs namespace. This name must be globally unique.
- Location: Select the Azure region where you want to deploy your namespace.
- Pricing tier: Choose the appropriate pricing tier (Basic, Standard, Premium). For most use cases, "Standard" is recommended.
-
Review and Create
Click "Review + create" to validate your settings. Once validation passes, click "Create" to deploy the namespace.
Deployment may take a few minutes.
-
Access Your Namespace
Once the deployment is complete, navigate to your newly created Event Hubs namespace. You can find it by searching for its name in the Azure portal.
-
Create an Event Hub
Inside your Event Hubs namespace, click on "+ Event Hub" in the top menu bar.
-
Configure Event Hub Settings
In the "Create Event Hub" pane, provide the following:
- Name: Enter a name for your Event Hub (e.g.,
myeventhub). - Partition count: This determines the number of parallel streams for processing. Start with a reasonable number (e.g., 2 or 4) and adjust based on your needs.
- Message retention: Specify how long events should be retained in the hub (e.g., 1 day, 7 days).
You can leave other settings as default for now.
- Name: Enter a name for your Event Hub (e.g.,
-
Create the Event Hub
Click the "Create" button. Your Event Hub will be provisioned within the namespace.
Next Steps
# Example of creating an Event Hubs Namespace and Event Hub using Azure CLI
echo "Creating a resource group..."
az group create --name "myResourceGroup" --location "West US"
echo "Creating an Event Hubs namespace..."
az eventhubs namespace create \
--resource-group "myResourceGroup" \
--name "my-unique-eventhub-namespace" \
--location "West US" \
--sku "Standard" "1000RU"
echo "Creating an Event Hub within the namespace..."
az eventhubs eventhub create \
--resource-group "myResourceGroup" \
--namespace-name "my-unique-eventhub-namespace" \
--name "myeventhub" \
--partition-count 2 \
--message-retention-in-days 7