Microsoft Azure Communication Network Traversal Service Client Library for Python
Project description
Azure Communication Network Traversal Package client library for Python
Azure Communication Network Traversal is managing TURN credentials for Azure Communication Services.
It will provide TURN credentials to a user.
Source code | API reference documentation
Getting started
Prerequisites
- Python 2.7, or 3.6 or later is required to use this package.
- You must have an Azure subscription
- A deployed Communication Services resource. You can use the Azure Portal or the Azure PowerShell to set it up.
Install the package
Install the Azure Communication Identity client library for Python with pip: Install the Azure Communication Relay Client library for Python with pip:
pip install azure-communication-identity
pip install azure-communication-networktraversal
Key concepts
Examples
Initializing Relay Client
The following section provides code snippets covering some of the most common Azure Communication Network Traversal tasks, including:
# 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())
#You can also authenticate using your connection string
identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string)
relay_client = CommunicationRelayClient.from_connection_string(self.connection_string)
Getting the relay configuration
# We need a user from Identity
user = identity_client.create_user()
relay_configuration = relay_client.get_relay_configuration(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)
Troubleshooting
The Azure Communication Relay client will raise exceptions defined in Azure Core.
Next steps
More sample code
Provide Feedback
If you encounter any bugs or have suggestions, please file an issue in the Issues section of the project
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file azure-communication-networktraversal-1.0.0b1.zip
.
File metadata
- Download URL: azure-communication-networktraversal-1.0.0b1.zip
- Upload date:
- Size: 53.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e45fe98c7ab69b8ff5dab1164832459d66a9f5c9eb4c686f5f7d6dbd93e4d4b |
|
MD5 | 8e040655b32f8984d10003dae1770b72 |
|
BLAKE2b-256 | 9207f57ecc3c144dec04da63e296e5968312f349f29f9a89dabd5a0388e8b436 |
File details
Details for the file azure_communication_networktraversal-1.0.0b1-py2.py3-none-any.whl
.
File metadata
- Download URL: azure_communication_networktraversal-1.0.0b1-py2.py3-none-any.whl
- Upload date:
- Size: 32.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf385d6d5249ba2457e6fed776ff17f1990a000fcd67c601d2ef4167519f301c |
|
MD5 | bf8400751fca707968be519e1af58228 |
|
BLAKE2b-256 | e47af9abdb35c4831fbc8cdbe4baa99021c67215e673bc7839d1ca3338ba8c96 |