Azure Event Hubs API Reference
Core Concepts
This section details the various APIs available for interacting with Azure Event Hubs, enabling you to send and receive events, manage your Event Hubs resources, and integrate with other Azure services.
Producer API
APIs for sending events to an Event Hub.
Send a batch of events to a specific Event Hub. Events can be batched for efficiency.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
namespaceName |
string | The name of the Event Hubs namespace. | Path |
eventHubName |
string | The name of the Event Hub within the namespace. | Path |
api-version |
string | The API version to use for the request. | Query |
Request Body
{
"events": [
{
"body": "Base64EncodedEventData",
"properties": {
"key1": "value1",
"key2": "value2"
},
"partitionKey": "optionalPartitionKey"
},
// ... more events
]
}
Success Response (201 Created)
{
"sequenceNumbers": [123, 124],
"offset": "someOffset",
"partitionId": "0",
" குறித்த": "someETag"
}
Send a batch of events to a specific partition within an Event Hub.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
namespaceName |
string | The name of the Event Hubs namespace. | Path |
eventHubName |
string | The name of the Event Hub within the namespace. | Path |
partitionId |
string | The ID of the target partition. | Path |
api-version |
string | The API version to use for the request. | Query |
Request Body
{
"events": [
{
"body": "Base64EncodedEventData",
"properties": {
"key1": "value1"
}
}
]
}
Success Response (201 Created)
{
"sequenceNumbers": [125],
"offset": "anotherOffset",
"partitionId": "1",
" குறித்த": "anotherETag"
}
Consumer API
APIs for reading events from an Event Hub.
Retrieve a batch of events from the beginning of a specific partition. Used for initial consumption or replaying events.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
namespaceName |
string | The name of the Event Hubs namespace. | Path |
eventHubName |
string | The name of the Event Hub within the namespace. | Path |
partitionId |
string | The ID of the partition to read from. | Path |
maxSizeInMB |
integer | The maximum size in MB for the returned batch. | Query |
api-version |
string | The API version to use for the request. | Query |
Success Response (200 OK)
{
"events": [
{
"body": "Base64EncodedEventData",
"properties": {
"key1": "value1"
},
"sequenceNumber": 100,
"offset": "offset100",
" குறித்த": "etag100",
"enqueuedTimeUtc": "2023-10-27T10:00:00Z"
},
// ... more events
]
}
Retrieve the next batch of events from a specific partition, starting from the specified offset.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
namespaceName |
string | The name of the Event Hubs namespace. | Path |
eventHubName |
string | The name of the Event Hub within the namespace. | Path |
partitionId |
string | The ID of the partition to read from. | Path |
offset |
string | The offset to start reading from. | Query |
api-version |
string | The API version to use for the request. | Query |
Success Response (200 OK)
{
"events": [
{
"body": "Base64EncodedEventData",
"properties": {
"key2": "value2"
},
"sequenceNumber": 105,
"offset": "offset105",
" குறித்த": "etag105",
"enqueuedTimeUtc": "2023-10-27T10:05:00Z"
}
]
}
Management API
APIs for managing Event Hubs resources like namespaces, Event Hubs, and consumer groups.
Get the properties of a specific Event Hubs namespace.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
subscriptionId |
string | Your Azure subscription ID. | Path |
resourceGroupName |
string | The name of the resource group. | Path |
namespaceName |
string | The name of the Event Hubs namespace. | Path |
api-version |
string | The API version for management operations. | Query |
Success Response (200 OK)
{
"id": "/subscriptions/.../namespaces/myNamespace",
"name": "myNamespace",
"type": "Microsoft.EventHub/namespaces",
"location": "West US",
"sku": {
"name": "Standard",
"tier": "Standard"
},
"properties": {
"provisioningState": "Succeeded",
"status": "Active"
}
}
Create or update an Event Hub within a namespace.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
subscriptionId |
string | Your Azure subscription ID. | Path |
resourceGroupName |
string | The name of the resource group. | Path |
namespaceName |
string | The name of the Event Hubs namespace. | Path |
eventHubName |
string | The name of the Event Hub to create or update. | Path |
api-version |
string | The API version for management operations. | Query |
Request Body
{
"properties": {
"messageRetentionInDays": 7,
"partitionCount": 2
}
}
Success Response (201 Created / 200 OK)
{
"id": "/subscriptions/.../namespaces/myNamespace/eventhubs/myEventHub",
"name": "myEventHub",
"type": "Microsoft.EventHub/namespaces/eventhubs",
"properties": {
"messageRetentionInDays": 7,
"partitionCount": 2,
"createdTime": "2023-10-27T11:00:00Z",
"updatedTime": "2023-10-27T11:00:00Z"
}
}
SDK Guides
Explore guides for using Azure Event Hubs with various SDKs:
Tutorials
Step-by-step tutorials for common Event Hubs scenarios: