Install & Compatibility
Where this runs
tested against v12.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.658s · 45MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.1s · import 0.594s · 45MB
47MB installed
● package 47MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
EventHubManagementClient
✓ from azure.mgmt.eventhub import EventHubManagementClient
DefaultAzureCredential
✓ from azure.identity import DefaultAzureCredential
This quickstart demonstrates how to authenticate with `DefaultAzureCredential` and use the `EventHubManagementClient` to list existing Event Hub namespaces and Event Hubs within a specified resource group. Ensure you have an existing Azure resource group and Event Hub namespace, and appropriate environment variables set for authentication or log in via Azure CLI (`az login`).
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.eventhub import EventHubManagementClient
# Set these environment variables or replace with actual values
# AZURE_SUBSCRIPTION_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID
# Or log in via Azure CLI: `az login`
SUBSCRIPTION_ID = os.environ.get("AZURE_SUBSCRIPTION_ID", "<your-subscription-id>")
RESOURCE_GROUP_NAME = os.environ.get("AZURE_RESOURCE_GROUP_NAME", "<existing-resource-group>")
EVENTHUB_NAMESPACE_NAME = os.environ.get("AZURE_EVENTHUB_NAMESPACE_NAME", "<existing-eventhub-namespace>")
def main():
if SUBSCRIPTION_ID == "<your-subscription-id>" or \
RESOURCE_GROUP_NAME == "<existing-resource-group>" or \
EVENTHUB_NAMESPACE_NAME == "<existing-eventhub-namespace>":
print("Please set AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP_NAME, and AZURE_EVENTHUB_NAMESPACE_NAME environment variables or replace placeholders.")
return
credential = DefaultAzureCredential()
client = EventHubManagementClient(credential, SUBSCRIPTION_ID)
print(f"Listing Event Hub Namespaces in resource group '{RESOURCE_GROUP_NAME}':")
try:
namespaces = client.namespaces.list_by_resource_group(RESOURCE_GROUP_NAME)
for namespace in namespaces:
print(f"- {namespace.name} (Location: {namespace.location})")
# List Event Hubs within this namespace
print(f" Listing Event Hubs in namespace '{namespace.name}':")
event_hubs = client.event_hubs.list_by_namespace(RESOURCE_GROUP_NAME, namespace.name)
for event_hub in event_hubs:
print(f" - {event_hub.name} (Partitions: {event_hub.partition_count})")
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure the resource group and namespace exist and your credentials have access.")
if __name__ == "__main__":
main()
Debug
Known issues
breakingOlder versions (prior to v4/v5) of Azure management libraries used `msrestazure.azure_active_directory` for authentication. Current stable versions (v11+) require `azure.identity` for credential handling.fixMigrate your authentication code to use `azure.identity.DefaultAzureCredential` or other `azure.identity` credential types. Install `azure-identity` if not already present (`pip install azure-identity`).
affects: < 4.0.0
breakingThe API surface and method signatures for creating and updating resources have significantly changed across major versions, particularly from older track 1 SDKs to the current track 2 SDKs. Object models for resource properties are also different.fixRefer to the official documentation and samples for the specific version (11.x.x) you are using. Methods like `create_or_update` now typically accept dedicated model objects (e.g., `EventHubNamespace`) directly, rather than individual parameters.
affects: All versions, especially major transitions (e.g., < 4.0.0 to 11.x.x)
gotchaMany list operations (e.g., `list_by_resource_group`, `list_by_namespace`) return `azure.core.paging.ItemPaged` objects, which are iterators. If you expect a plain list, you might need to convert it (e.g., `list(client.namespaces.list_by_resource_group(...))`) if you need random access or length upfront.fixAlways iterate directly over the `ItemPaged` object or explicitly convert it to a list if necessary. Do not assume it's a synchronous list operation.
affects: >= 4.0.0
gotchaResource creation methods (e.g., `namespaces.begin_create_or_update`) are often long-running operations and return a poller object. You must call `.result()` on the poller to wait for the operation to complete and get the final resource object.fixAlways call `.result()` on the poller returned by `begin_*` methods (e.g., `poller = client.namespaces.begin_create_or_update(...); namespace = poller.result()`).
affects: >= 4.0.0
Upgrade
Version history
12.0.0latest on PyPI · released Jul 30, 2026
Audit
Dependencies
azure-identityrequiredRequired for authentication with Azure services using modern credential types like DefaultAzureCredential.