0
# Azure Event Hub Management Client
1
2
A comprehensive Python management client library for Azure Event Hub services, enabling developers to programmatically manage Event Hub namespaces, event hubs, consumer groups, authorization rules, disaster recovery configurations, and dedicated clusters through the Azure Resource Manager API.
3
4
## Package Information
5
6
- **Package Name**: azure-mgmt-eventhub
7
- **Language**: Python
8
- **Installation**: `pip install azure-mgmt-eventhub`
9
- **Version**: 11.2.0
10
11
## Core Imports
12
13
```python
14
from azure.mgmt.eventhub import EventHubManagementClient
15
```
16
17
## Basic Usage
18
19
```python
20
from azure.mgmt.eventhub import EventHubManagementClient
21
from azure.identity import DefaultAzureCredential
22
23
# Initialize the management client
24
credential = DefaultAzureCredential()
25
subscription_id = "your-subscription-id"
26
client = EventHubManagementClient(credential, subscription_id)
27
28
# Create a namespace
29
from azure.mgmt.eventhub.models import EHNamespace, Sku
30
31
namespace_params = EHNamespace(
32
location="East US",
33
sku=Sku(name="Standard", tier="Standard")
34
)
35
36
namespace_operation = client.namespaces.begin_create_or_update(
37
resource_group_name="my-resource-group",
38
namespace_name="my-eventhub-namespace",
39
parameters=namespace_params
40
)
41
namespace = namespace_operation.result()
42
43
# Create an Event Hub
44
from azure.mgmt.eventhub.models import Eventhub
45
46
eventhub_params = Eventhub(
47
message_retention_in_days=7,
48
partition_count=4
49
)
50
51
eventhub = client.event_hubs.create_or_update(
52
resource_group_name="my-resource-group",
53
namespace_name="my-eventhub-namespace",
54
event_hub_name="my-eventhub",
55
parameters=eventhub_params
56
)
57
58
# List Event Hubs in namespace
59
eventhubs = client.event_hubs.list_by_namespace(
60
resource_group_name="my-resource-group",
61
namespace_name="my-eventhub-namespace"
62
)
63
64
for eh in eventhubs:
65
print(f"Event Hub: {eh.name}")
66
```
67
68
## Architecture
69
70
The client uses Azure SDK's multi-API version architecture, supporting multiple API versions with 2024-01-01 as the default. Key components include:
71
72
- **EventHubManagementClient**: Main client class providing access to all operation groups
73
- **Operation Groups**: Specialized managers for different resource types (namespaces, event_hubs, clusters, etc.)
74
- **Models**: Rich data models representing Azure Event Hub resources and configuration
75
- **Multi-API Support**: Backward compatibility with older API versions (2015-08-01 through 2024-05-01-preview)
76
- **Async Support**: Full async/await support through aio submodules
77
78
**Note**: Not all operation groups are available in every API version. The default API version 2024-01-01 includes all currently documented operations. For legacy operations like `regions`, you may need to specify an older API version like 2017-04-01.
79
80
## Capabilities
81
82
### Core Management
83
84
Primary Event Hub resource management including namespaces, Event Hubs, and consumer groups. These are the fundamental building blocks for Event Hub solutions.
85
86
```python { .api }
87
class EventHubManagementClient:
88
def __init__(
89
self,
90
credential: TokenCredential,
91
subscription_id: str,
92
api_version: Optional[str] = None,
93
base_url: str = "https://management.azure.com",
94
profile: KnownProfiles = KnownProfiles.default,
95
**kwargs: Any
96
): ...
97
98
@property
99
def namespaces(self) -> NamespacesOperations: ...
100
101
@property
102
def event_hubs(self) -> EventHubsOperations: ...
103
104
@property
105
def consumer_groups(self) -> ConsumerGroupsOperations: ...
106
```
107
108
[Core Management](./core-management.md)
109
110
### Security and Access Control
111
112
Comprehensive security management including authorization rules, private endpoints, network rules, and managed identity configuration for secure Event Hub access.
113
114
```python { .api }
115
class AuthorizationRule:
116
def __init__(
117
self,
118
rights: Optional[List[Union[str, AccessRights]]] = None,
119
**kwargs: Any
120
): ...
121
122
class NetworkRuleSet:
123
def __init__(
124
self,
125
default_action: Optional[Union[str, DefaultAction]] = None,
126
virtual_network_rules: Optional[List[NWRuleSetVirtualNetworkRules]] = None,
127
ip_rules: Optional[List[NWRuleSetIpRules]] = None,
128
**kwargs: Any
129
): ...
130
```
131
132
[Security and Access Control](./security-access-control.md)
133
134
### Enterprise Features
135
136
Advanced enterprise capabilities including dedicated clusters, disaster recovery, schema registry, and application groups for production-scale Event Hub deployments.
137
138
```python { .api }
139
@property
140
def clusters(self) -> ClustersOperations: ...
141
142
@property
143
def disaster_recovery_configs(self) -> DisasterRecoveryConfigsOperations: ...
144
145
@property
146
def schema_registry(self) -> SchemaRegistryOperations: ...
147
148
@property
149
def application_group(self) -> ApplicationGroupOperations: ...
150
```
151
152
[Enterprise Features](./enterprise-features.md)
153
154
### Network Security Perimeter
155
156
Advanced network security perimeter management for controlling access boundaries and resource associations in enterprise environments.
157
158
```python { .api }
159
@property
160
def network_security_perimeter_configuration(self) -> NetworkSecurityPerimeterConfigurationOperations:
161
"""Network security perimeter configuration operations."""
162
163
@property
164
def network_security_perimeter_configurations(self) -> NetworkSecurityPerimeterConfigurationsOperations:
165
"""Network security perimeter configurations operations."""
166
```
167
168
**Operations**:
169
- `network_security_perimeter_configuration.list(resource_group_name, namespace_name, **kwargs) -> Iterable[NetworkSecurityPerimeterConfiguration]` - List network security perimeter configurations
170
- `network_security_perimeter_configurations.begin_create_or_update(resource_group_name, namespace_name, resource_association_name, **kwargs) -> LROPoller[None]` - Create or update network security perimeter configuration
171
172
### Utility Operations
173
174
Service discovery operations for listing available Azure Event Hub operations.
175
176
```python { .api }
177
@property
178
def operations(self) -> Operations:
179
"""List available Event Hub management operations."""
180
```
181
182
**Operations**:
183
- `operations.list(**kwargs) -> Iterable[Operation]` - List all available REST API operations
184
185
## Error Handling
186
187
The client raises standard Azure SDK exceptions:
188
189
```python
190
from azure.core.exceptions import (
191
HttpResponseError,
192
ResourceNotFoundError,
193
ResourceExistsError,
194
ClientAuthenticationError
195
)
196
197
try:
198
namespace = client.namespaces.get("resource-group", "namespace-name")
199
except ResourceNotFoundError:
200
print("Namespace not found")
201
except ClientAuthenticationError:
202
print("Authentication failed")
203
except HttpResponseError as e:
204
print(f"HTTP error: {e.status_code} - {e.message}")
205
```
206
207
## Types
208
209
```python { .api }
210
from typing import Optional, List, Union, Any
211
from azure.core.credentials import TokenCredential
212
from azure.profiles import KnownProfiles
213
214
# Core enums
215
class AccessRights(str, Enum):
216
MANAGE = "Manage"
217
SEND = "Send"
218
LISTEN = "Listen"
219
220
class SkuName(str, Enum):
221
BASIC = "Basic"
222
STANDARD = "Standard"
223
PREMIUM = "Premium"
224
225
class EntityStatus(str, Enum):
226
ACTIVE = "Active"
227
DISABLED = "Disabled"
228
RESTORING = "Restoring"
229
SEND_DISABLED = "SendDisabled"
230
RECEIVE_DISABLED = "ReceiveDisabled"
231
CREATING = "Creating"
232
DELETING = "Deleting"
233
RENAMING = "Renaming"
234
UNKNOWN = "Unknown"
235
236
# Core model base classes
237
class Resource:
238
def __init__(self, **kwargs: Any): ...
239
240
id: Optional[str]
241
name: Optional[str]
242
type: Optional[str]
243
244
class TrackedResource(Resource):
245
def __init__(
246
self,
247
location: Optional[str] = None,
248
tags: Optional[Dict[str, str]] = None,
249
**kwargs: Any
250
): ...
251
252
location: Optional[str]
253
tags: Optional[Dict[str, str]]
254
255
class NetworkSecurityPerimeterConfiguration:
256
def __init__(
257
self,
258
network_security_perimeter: Optional[NetworkSecurityPerimeter] = None,
259
resource_association: Optional[ResourceAssociation] = None,
260
profile: Optional[NetworkSecurityPerimeterConfigurationProfile] = None,
261
**kwargs: Any
262
): ...
263
```