Getting Started with Azure Event Hubs

Welcome to the Getting Started guide for Azure Event Hubs! This section will walk you through the essential steps to set up and begin using Event Hubs for your event streaming needs.

1. Prerequisites

2. Create an Event Hubs Namespace

An Event Hubs namespace is a logical container for Event Hubs. All Event Hubs and consumer groups reside within a namespace.

Using Azure Portal:

  1. Navigate to the Azure portal.
  2. Click on "Create a resource".
  3. Search for "Event Hubs" and select it.
  4. Click "Create".
  5. Select your subscription and resource group.
  6. Enter a unique namespace name.
  7. Choose a location.
  8. Select a pricing tier (e.g., Basic or Standard).
  9. Click "Review + create", then "Create".

Using Azure CLI:


az group create --name MyEventHubsResourceGroup --location eastus
az eventhubs namespace create --name MyEventHubsNamespace --resource-group MyEventHubsResourceGroup --location eastus
            

3. Create an Event Hub

An Event Hub is the actual streaming entity where events are sent and read from.

Using Azure Portal:

  1. Once your Event Hubs namespace is created, navigate to it in the Azure portal.
  2. Click on "+ Event Hub".
  3. Enter a name for your Event Hub (e.g., myeventhub).
  4. Configure settings like message retention and partitioning if needed.
  5. Click "Create".

Using Azure CLI:


az eventhubs eventhub create --name myeventhub --namespace-name MyEventHubsNamespace --resource-group MyEventHubsResourceGroup
            

4. Get Connection Strings

To send or receive events, you'll need connection strings. These contain authentication and endpoint information.

Using Azure Portal:

  1. Navigate to your Event Hubs namespace.
  2. Under "Settings", click "Shared access policies".
  3. You can use the "RootManageSharedAccessKey" for convenience, or create a custom policy with specific permissions.
  4. Click on a policy name to view its keys and connection strings. Copy the "Primary Connection String".

Using Azure CLI:


az eventhubs authorization-rule list --namespace-name MyEventHubsNamespace --resource-group MyEventHubsResourceGroup --output table
# From the output, find the connection string for your chosen policy (e.g., RootManageSharedAccessKey)
            

It's recommended to create specific policies for sending and receiving operations rather than using the root key in production environments.

5. Install an SDK

Azure Event Hubs offers SDKs for various programming languages. Choose the one that best suits your application.

For example, to install the Python SDK:


pip install azure-eventhub
            

Next Steps

Now that you have Event Hubs set up and an SDK installed, you're ready to start sending and receiving events. Proceed to the Sending Events guide.

Send Your First Event