你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

适用于 Python 的 Microsoft Azure SDK

这是 Microsoft Azure 服务总线 管理客户端库。 此包已使用 Python 3.7+ 进行了测试。 有关 Azure 库的更完整视图,请参阅 azure sdk python 版本

免责声明

对 Python 2.7 的 Azure SDK Python 包支持已于 2022 年 1 月 1 日结束。 有关详细信息和问题,请参阅 https://github.com/Azure/azure-sdk-for-python/issues/20691

入门

先决条件

安装包

pip install azure-mgmt-servicebus
pip install azure-identity

身份验证

默认情况下, Azure Active Directory 令牌身份验证依赖于以下环境变量的正确配置。

  • AZURE_CLIENT_ID 用于 Azure 客户端 ID。
  • AZURE_TENANT_ID 用于 Azure 租户 ID。
  • AZURE_CLIENT_SECRET 用于 Azure 客户端机密。

此外,可以通过环境变量 AZURE_SUBSCRIPTION_ID配置 Azure 订阅 ID。

使用上述配置,可以通过以下代码对客户端进行身份验证:

from azure.identity import DefaultAzureCredential
from azure.mgmt.servicebus import ServiceBusManagementClient
import os

sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
client = ServiceBusManagementClient(credential=DefaultAzureCredential(), subscription_id=sub_id)

示例

有关此包的代码示例,请参阅 docs.microsoft.com 和示例存储库上的服务总线管理

疑难解答

后续步骤

提供反馈

如果遇到任何 bug 或有建议,请在项目的“ 问题 ”部分中提出问题。

曝光数