Microsoft Azure Communication Network Traversal Service Client Library for Python
项目描述
Azure Communication Network Traversal Package客户端库
请注意,此包已被弃用,并将在2024年3月31日之后不再维护。
Azure Communication Network Traversal负责管理Azure Communication Services的TURN凭据。
它将为用户提供TURN凭据。
免责声明
Azure SDK Python包对Python 2.7的支持已于2022年1月1日结束。有关更多信息,请参阅 https://github.com/Azure/azure-sdk-for-python/issues/20691
入门
请注意,此包已被弃用,并将在2024年3月31日之后不再维护。
关键概念
示例
初始化中继客户端
以下部分提供了代码片段,涵盖了 Azure 通信网络遍历的一些常见任务,包括
# You can find your endpoint and access token from your resource in the Azure Portal
import os
from azure.communication.networktraversal import CommunicationRelayClient
from azure.identity import DefaultAzureCredential
from azure.communication.identity import CommunicationIdentityClient
connection_str = "endpoint=ENDPOINT;accessKey=KEY"
endpoint = "https://<RESOURCE_NAME>.communication.azure.com"
# To use Azure Active Directory Authentication (DefaultAzureCredential) make sure to have
# AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET as env variables.
# We also need Identity client to get a User Identifier
identity_client = CommunicationIdentityClient(endpoint, DefaultAzureCredential())
relay_client = CommunicationRelayClient(endpoint, DefaultAzureCredential())
您也可以使用连接字符串进行认证
identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string)
relay_client = CommunicationRelayClient.from_connection_string(self.connection_string)
通过用户获取中继配置
# We need a user from Identity
user = identity_client.create_user()
relay_configuration = relay_client.get_relay_configuration(user=user)
for iceServer in config.ice_servers:
assert iceServer.username is not None
print('Username: ' + iceServer.username)
assert iceServer.credential is not None
print('Credential: ' + iceServer.credential)
assert iceServer.urls is not None
for url in iceServer.urls:
print('Url:' + url)
不提供用户获取中继配置
relay_configuration = relay_client.get_relay_configuration()
for iceServer in config.ice_servers:
assert iceServer.username is not None
print('Username: ' + iceServer.username)
assert iceServer.credential is not None
print('Credential: ' + iceServer.credential)
assert iceServer.urls is not None
for url in iceServer.urls:
print('Url:' + url)
不提供 RouteType 获取中继配置
# We need a user from Identity
user = identity_client.create_user()
relay_configuration = relay_client.get_relay_configuration(user=user, route_type=RouteType.NEAREST)
for iceServer in config.ice_servers:
assert iceServer.username is not None
print('Username: ' + iceServer.username)
assert iceServer.credential is not None
print('Credential: ' + iceServer.credential)
assert iceServer.urls is not None
for url in iceServer.urls:
print('Url:' + url)
故障排除
Azure 通信中继客户端将抛出在 Azure Core 中定义的异常。
下一步
更多示例代码
提供反馈
如果您遇到任何错误或有建议,请在项目的 问题 部分提交问题。
贡献
本项目欢迎贡献和建议。大多数贡献需要您同意贡献者许可协议 (CLA),声明您有权并且实际上确实授予我们使用您的贡献的权利。有关详细信息,请访问 https://cla.microsoft.com。
提交拉取请求时,CLA-bot 将自动判断您是否需要提供 CLA,并相应地装饰 PR(例如,标签、注释)。只需按照机器人提供的说明操作。您只需在整个使用我们的 CLA 的所有仓库中这样做一次。
本项目已采用 Microsoft 开源行为准则。有关更多信息,请参阅 行为准则常见问题解答 或通过 opencode@microsoft.com 联系我们,提出任何额外的问题或评论。
散列 for azure-communication-networktraversal-1.1.0b2.tar.gz
算法 | 散列摘要 | |
---|---|---|
SHA256 | d6a7125bb0069634544378e5181dcfc6009411a97d2db3451657751cf8b411ae |
|
MD5 | 917a96d7f01df7c755487eafcd3dd923 |
|
BLAKE2b-256 | c85a95acfcd8b6e2244f3185ff0858cfae9d036bdffccc5172c59310e0654f2f |
散列 for azure_communication_networktraversal-1.1.0b2-py3-none-any.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | cdd5fa0c219f22c5ae2f63e6ed74b00477677293131fbdb68e285b6edff09bd1 |
|
MD5 | 217a029abc61504f4911620e2cd2fb2e |
|
BLAKE2b-256 | dddb32d174fac9bf2e637918ce7d621e04a14418048af6bfeedb1806e88ebbc9 |