Skip to main content

Microsoft Azure Communication Management Client Library for Python

Project description

Microsoft Azure SDK for Python

This is the Microsoft Azure Communication Management Client Library. This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. For a more complete view of Azure libraries, see the azure sdk python release.

Usage

For additional code examples, see Communication Service Management on docs.microsoft.com.

Prerequisites

See the Python developer guide to configure your dev environment and set the needed environment variables.

Examples

Authentication

This example authenticates to Azure using a service principal. Documentation on creating and managing a service principal in AAD can be found here.

def __create_communication_management_client(credentials):
    subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID");
    if subscription_id is None:
        return None

    return CommunicationServiceManagementClient(credentials, subscription_id)

def __create_service_principal_credentials():
    # service principal's app id; `<your-app-id>`
    app_id = os.environ.get("AZURE_CLIENT_ID");
    # one of the service principal's client secrets; `<your-password>`
    client_secret = os.environ.get("AZURE_CLIENT_SECRET");
    # id of the principal's Azure Active Directory tenant; `<your-tenant-id>`
    tenant_id = os.environ.get("AZURE_TENANT_ID");

    if app_id is None or client_secret is None or tenant_id is None:
        return None

    return ServicePrincipalCredentials(client_id=app_id, secret=client_secret, tenant=tenant_id)

Create a communication service resource

def __create_communication_service(mgmt_client, resourceGroupName, resourceName):
    resource = CommunicationServiceResource(location="global", data_location = "UnitedStates")
    mgmt_client.communication_service.create_or_update(resourceGroupName, resourceName, resource)

List all communication services

def __list_communication_service(mgmt_client):
    resources = mgmt_client.communication_service.list_by_subscription();
    for resource in resources:
        print(resource)

Delete a communication service

def __delete_communication_service(mgmt_client, resourceGroupName, resourceName):
    mgmt_client.communication_service.delete(resourceGroupName, resourceName)

Provide Feedback

If you encounter any bugs or have suggestions, please file an issue in the Issues section of the project.

Release History

1.0.0b1 (2020-09-22)

  • Initial Release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azure-mgmt-communication-1.0.0b1.zip (31.2 kB view hashes)

Uploaded Source

Built Distribution

azure_mgmt_communication-1.0.0b1-py2.py3-none-any.whl (23.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page