Skip to main content

Azure Communication Rooms client library for Python

This package contains a Python SDK for Azure Communication Services for Rooms. Read more about Azure Communication Services here

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

Key concepts

The Azure Communication Rooms package is used to do following:

  • Create scheduled meetings
  • Create meetings with managed permissions for its participants

Getting started

Installating the package

python -m pip install azure-communication-rooms

Prequisites

Client Initialization

To initialize the Rooms Client, the connection string can be used to instantiate.

from azure.communication.rooms import RoomsClient

client = RoomsClient.from_connection_string(conn_str='<connection_str>' )

Examples

Key parameters

  • valid_from: A datetime object from which room will start existing
  • valid_until: A datetime object after which room meeting would end
  • participants: A list of RoomParticipants containing MRI's of invitees to the room as well as optional ParticipantRole. If ParticipantRole is not specified, then it will be Attendee by default. All the above attributes are optional. The service provides default values of valid_until and valid_from if they are missing. The default forvalid_from is current date time and the default for valid_until is valid_from + 180 days.
  • pstn_dial_out_enabled: Set this flag to true if, at the time of the call, dial out to a PSTN number is enabled in a particular room. This flag is optional.

Create a room

To create a room, call the create_room function from RoomsClient. The valid_from, valid_until, and participants arguments are all optional. Starting in 1.1.0 release, ACS Rooms supports PSTN Dial-Out feature. To create room with PSTN Dial-Out property, call create_room function and set pstn_dial_out_enabled to either true or false. If pstn_dial_out_enabled is not provided, then the default value for pstn_dial_out_enabled is false.

from azure.core.exceptions import HttpResponseError
from datetime import datetime, timedelta
from azure.communication.rooms import (
    RoomsClient,
    RoomParticipant,
    ParticipantRole
)
from azure.communication.identity import CommunicationUserIdentifier
from dateutil.relativedelta import relativedelta

client = RoomsClient.from_connection_string(conn_str='<connection_str>')
valid_from = datetime.now()
valid_until = valid_from + relativedelta(months=+1)
participants = []
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 1>")))
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 2>"), role=ParticipantRole.CONSUMER))
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 3>"), role=ParticipantRole.PRESENTER))

try:
    create_room_response = client.create_room(
        valid_from=valid_from,
        valid_until=valid_until,
        participants=participants,
        pstn_dial_out_enabled=false

    )
except HttpResponseError as ex:
    print(ex)

Update a room

The valid_from and valid_until properties of a created room can be updated by calling the update_room function from RoomsClient. Starting in 1.1.0 release, ACS Rooms supports PSTN Dial-Out feature. To update a room with PSTN Dial-Out property, call update_room and set pstn_dial_out_enabled to either true or false. If pstn_dial_out_enabled is not provided, then there is no changes to PstnDialOutEnabled property in the room.

try:
    update_room_response = client.update_room(
        room_id="id of the room to be updated",
        valid_from=datetime.now(),
        valid_until=valid_from + timedelta(weeks=4),
        pstn_dial_out_enabled=false
    )
except HttpResponseError as e:
    print('service responds error: {}'.format(e))

Get a room

A created room can be retrieved by calling the get_room function from RoomsClient and passing in the associated room_id.

try:
    get_room_response = client.get_room(room_id="id of the room to get")
except HttpResponseError as ex:
    print(ex)

List rooms

Retrieve all valid rooms created with an ACS resource by calling the list_rooms function from RoomsClient.

try:
    list_room_response = client.list_rooms()
except HttpResponseError as ex:
    print(ex)

Delete a room

To delete a room, call the delete_room function from RoomsClient.

try:
    client.delete_room(
        room_id="id of the room to be deleted")
except HttpResponseError as e:
    print('service responds error: {}'.format(e))

Add or update participants in a room

In order to insert new participants or update existing participants, call the add_or_update_participants function from RoomsClient.

participants = []
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 1>")))
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 2>"), role=ParticipantRole.ATTENDEE))
participants.append(RoomParticipant(communication_identifier=CommunicationUserIdentifier("<ACS User MRI identity 3>"), role=ParticipantRole.CONSUMER))
try:
    response = client.add_or_update_participants(
        room_id="id of the room to be updated",
        participants=participants
    )
except HttpResponseError as e:
    print('service responds error: {}'.format(e))

Remove participants

Remove participants from a room by calling the remove_participants function from RoomsClient.

communication_identifiers = [CommunicationUserIdentifier("<ACS User MRI identity 2>")]

try:
    remove_participants_response = client.remove_participants(
        room_id="id of the room to remove participants",
        participants=communication_identifiers
    )
except HttpResponseError as ex:
    print(ex)

List participants

Retrieve the list of participants for an existing room by referencing the room_id:

try:
    participants = client.list_participants(room_id="id of the room to list participants")
except HttpResponseError as ex:
    print(ex)

Troubleshooting

Rooms operations will throw an exception if the request to the server fails. The Rooms client will raise exceptions defined in Azure Core.

Next steps

More sample code

Please take a look at the samples directory for detailed examples of how to use this library to create and manage rooms.

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.

Metadata

Release files for azure-communication-rooms 1.2.0

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-rooms 1.2.0
File Size Uploaded Provenance
azure_communication_rooms-1.2.0.tar.gz 62.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for azure-communication-rooms 1.2.0
File Interpreter ABI Platform
azure_communication_rooms-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 127.2 kB

Release files / azure_communication_rooms-1.2.0.tar.gz

Download URL azure_communication_rooms-1.2.0.tar.gz
Size 62.2 kB
Tags Source
SHA-256 checksum
How to use checksums
593520e2448c79694eff8d09baa46ab3212d8038901c21f15fd5d6216e3c3ea0
BLAKE2b-256 checksum
How to use checksums
426cf721f66b089ac8f238668ad587f2408237d8094a46abb23d0ff5fb6e3933
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / azure_communication_rooms-1.2.0-py3-none-any.whl

Download URL azure_communication_rooms-1.2.0-py3-none-any.whl
Size 65.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7996e009a2eef0b750c48278e1447fd9a5f618dd2b4990f910c663c6ee5b7aa7
BLAKE2b-256 checksum
How to use checksums
b340c1f70fd36d1f21495f988b023698dabbbcaa9a326a7706ed0fd001bbdba6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Security for azure-communication-rooms 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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