Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Azure Communication Network Traversal Package client library for Python

Please note, this package has been deprecated and will no longer be maintained after 03/31/2024.

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

Disclaimer

Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691

Getting started

Please note, this package has been deprecated and will no longer be maintained after 03/31/2024.

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 providing a user

# 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)

Getting the relay configuration without providing a user

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)

Getting the relay configuration without providing a 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)

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.

Release files for azure-communication-networktraversal 1.1.0b2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for azure-communication-networktraversal 1.1.0b2
File Size Uploaded
azure-communication-networktraversal-1.1.0b2.tar.gz 31.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for azure-communication-networktraversal 1.1.0b2
File Interpreter ABI Platform
azure_communication_networktraversal-1.1.0b2-py3-none-any.whl Python 3 none any Details

Total release size: 75.7 kB

Release files / azure-communication-networktraversal-1.1.0b2.tar.gz

Download URL azure-communication-networktraversal-1.1.0b2.tar.gz
Size 31.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d6a7125bb0069634544378e5181dcfc6009411a97d2db3451657751cf8b411ae
BLAKE2b-256 checksum
How to use checksums
c85a95acfcd8b6e2244f3185ff0858cfae9d036bdffccc5172c59310e0654f2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / azure_communication_networktraversal-1.1.0b2-py3-none-any.whl

Download URL azure_communication_networktraversal-1.1.0b2-py3-none-any.whl
Size 44.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cdd5fa0c219f22c5ae2f63e6ed74b00477677293131fbdb68e285b6edff09bd1
BLAKE2b-256 checksum
How to use checksums
dddb32d174fac9bf2e637918ce7d621e04a14418048af6bfeedb1806e88ebbc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page