Registry / azure / azure-mgmt-servicebus

azure-mgmt-servicebus

JSON →
library10.0.0pypypi✓ verified 25d ago

The `azure-mgmt-servicebus` library provides the client-side functionality for managing Azure Service Bus resources, such as namespaces, queues, and topics, through the Azure Resource Manager API. It is part of the broader Azure SDK for Python, currently at version 9.0.0, and follows a consistent release cadence with other Azure management libraries, typically updated monthly or bi-monthly with new API versions and features.

pip install azure-mgmt-servicebus azure-identity
INSTALL
IMPORT
SIG · AZURE-MGMT-SERVICE
A
azure-mgmt-servicebus
azurepythonv10.0.0
Install
3.9s avg
Import
611ms
Disk
44MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v10.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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.636s · 45.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.9s · import 0.586s · 46MB
44MB installed
● package 44MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ServiceBusManagementClient
from azure.mgmt.servicebus import ServiceBusManagementClient
DefaultAzureCredential
from azure.identity import DefaultAzureCredential
from azure.common.credentials import ServicePrincipalCredentials
Old credential types are deprecated; use azure-identity for modern authentication.

This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and then use `ServiceBusManagementClient` to list and retrieve Service Bus namespaces within a specified resource group. Ensure `AZURE_SUBSCRIPTION_ID` and `AZURE_RESOURCE_GROUP_NAME` environment variables are set for authentication and resource context.

import os from azure.identity import DefaultAzureCredential from azure.mgmt.servicebus import ServiceBusManagementClient # Set your Azure Subscription ID and Resource Group in environment variables or replace directly. subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_SUBSCRIPTION_ID') resource_group_name = os.environ.get('AZURE_RESOURCE_GROUP_NAME', 'my-servicebus-rg') namespace_name = os.environ.get('AZURE_SERVICEBUS_NAMESPACE', 'my-servicebus-namespace') if subscription_id == 'YOUR_SUBSCRIPTION_ID': raise ValueError("Please set the AZURE_SUBSCRIPTION_ID environment variable.") # Authenticate using DefaultAzureCredential (looks for env vars, managed identity, etc.) credential = DefaultAzureCredential() # Create a Service Bus Management Client servicebus_client = ServiceBusManagementClient(credential, subscription_id) try: # Example: List all Service Bus namespaces in a resource group print(f"Listing Service Bus namespaces in resource group '{resource_group_name}':") namespaces = servicebus_client.namespaces.list_by_resource_group(resource_group_name) for ns in namespaces: print(f" - {ns.name} (Location: {ns.location}, Status: {ns.status})") # Example: Get a specific Service Bus namespace (if it exists) print(f"\nGetting Service Bus namespace '{namespace_name}':") try: ns_details = servicebus_client.namespaces.get(resource_group_name, namespace_name) print(f" Namespace '{ns_details.name}' found. Status: {ns_details.status}") except Exception as e: print(f" Namespace '{namespace_name}' not found or error: {e}") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingMajor versions of Azure Management SDKs, especially from v7 onwards, introduced significant breaking changes. These often include the separation of synchronous and asynchronous clients, changes to method signatures (e.g., keyword-only arguments), and updates to model object structures. Upgrading from versions older than 7.x.x typically requires substantial code modification.
fix
Review the official migration guides for your specific previous version. Re-evaluate client instantiation, method calls, and how model objects are accessed. Consider using the `async` clients where appropriate for non-blocking I/O.
affects: <7.0.0 to 7.0.0+
gotchaThis library (`azure-mgmt-servicebus`) is strictly for *managing* Service Bus resources (creating namespaces, queues, topics, etc.). It does *not* provide functionality for sending or receiving messages from Service Bus queues or topics. For data plane operations, you need to use the `azure-servicebus` library.
fix
If your goal is to send or receive messages, use `pip install azure-servicebus`. If you need to manage the infrastructure, use `azure-mgmt-servicebus`.
affects: All
gotchaAuthentication mechanisms have evolved. Older examples might use `ServicePrincipalCredentials` directly, which is now deprecated. The recommended approach is `azure-identity` (e.g., `DefaultAzureCredential`), which provides a unified way to authenticate across different Azure environments.
fix
Always use `azure-identity` for credential management. Ensure you have the `azure-identity` package installed and replace any direct credential instantiation with `DefaultAzureCredential()` or other appropriate `azure-identity` credential types.
affects: <7.0.0 to 7.0.0+
gotchaListing operations often return paginated iterators rather than a simple list. While these can often be iterated directly, for scenarios requiring explicit page-by-page processing (e.g., handling large result sets, tracking continuation tokens), you may need to use `by_page()` methods if available or handle the iterator carefully.
fix
When iterating over large result sets from list operations, be aware that the iterator might fetch items in batches. For fine-grained control or explicit pagination, consult the method's documentation for `by_page()` or similar options, especially in `async` contexts.
affects: All
gotchaThe Azure Management SDKs often require the `AZURE_SUBSCRIPTION_ID` environment variable to be set, as operations are scoped to a specific subscription. Attempting to initialize clients or perform operations without this variable can lead to errors like `ValueError: Please set the AZURE_SUBSCRIPTION_ID environment variable` or similar messages indicating a missing subscription.
fix
Ensure the `AZURE_SUBSCRIPTION_ID` environment variable is set to a valid Azure subscription ID before running your application. This can be done via `export AZURE_SUBSCRIPTION_ID='your_subscription_id'` in your shell, by configuring it in your deployment environment, or by passing the subscription ID directly to client constructors if supported.
affects: All
gotchaAzure Management SDKs typically require the `AZURE_SUBSCRIPTION_ID` environment variable (or passed explicitly) to identify the target subscription for operations. Failure to set this will prevent resource management operations from proceeding.
fix
Set the `AZURE_SUBSCRIPTION_ID` environment variable with your Azure subscription ID. Alternatively, if the client constructor supports it, pass the subscription ID explicitly.
affects: All
Upgrade
Version history
10.0.0latest on PyPI · released Jul 20, 2026
Audit
Dependencies
azure-commonrequiredCommon Azure SDK utilities.
azure-corerequiredCore utilities and HTTP pipeline for Azure SDKs.
msrestazurerequiredAzure-specific extensions for msrest.
azure-identityrequiredRecommended credential provider for authenticating with Azure services.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources