Azure Communication Rooms Client Library
raw JSON → 1.2.0 verified Fri May 01 auth: no python
Microsoft Azure Communication Rooms client library for Python. Used to manage and participate in virtual rooms (structured communications with role-based access and lifecycle). Current version: 1.2.0, stable release with regular updates aligned with Azure SDK for Python release cadence.
pip install azure-communication-rooms Common errors
error 'RoomsClient' object has no attribute 'create_room' ↓
cause Using an older version (<1.0.0) or importing from wrong module. The `create_room` method was introduced in the first stable release.
fix
Upgrade to latest version:
pip install --upgrade azure-communication-rooms and ensure import: from azure.communication.rooms import RoomsClient error AttributeError: module 'azure.communication.rooms' has no attribute 'RoomParticipant' ↓
cause Importing from a non-existent subpackage or version mismatch. `RoomParticipant` is available from version 1.0.0+ but may be called `ParticipantRole` incorrectly.
fix
Upgrade to >=1.0.0 and use correct import:
from azure.communication.rooms import RoomParticipant error ValueError: Invalid role. Valid roles are: Attendee, Consumer, Presenter ↓
cause Passing a string like 'Viewer' or 'Speaker' instead of the `ParticipantRole` enum.
fix
Use
ParticipantRole.ATTENDEE, ParticipantRole.CONSUMER, or ParticipantRole.PRESENTER (not their string counterparts). error HttpResponseError: (BadRequest) Participant identifier is not valid. ↓
cause The `communication_identifier` is malformed or not a valid Communication Services identity. It must start with '8:acs:' followed by the resource ID and user ID.
fix
Generate a valid identifier via
CommunicationIdentityClient.create_user() or use a known raw ID. error ModuleNotFoundError: No module named 'azure.communication' ↓
cause Missing base `azure-communication-rooms` package or incorrect installation order.
fix
Install the package:
pip install azure-communication-rooms. It includes the azure.communication namespace. Warnings
gotcha Do not import from private submodules (e.g., azure.communication.rooms._models). These are not part of the public API and may break in minor releases. Always import from the top-level package. ↓
fix Use: from azure.communication.rooms import RoomsClient, RoomParticipant, ParticipantRole
gotcha The `communication_identifier` parameter in `RoomParticipant` expects a user identifier string (e.g., from Communication Identity). Do not pass raw phone numbers or emails. Use the format like '8:acs:resourceId_userId'. ↓
fix Ensure the identifier is a valid Communication Services identifier, typically obtained from `CommunicationIdentityClient`.
breaking In version 1.0.0, the `list_rooms` method returned a sync iterator. In 1.1.0+, it supports async iteration. Code expecting a list may break if you try to index directly without converting. The items are `RoomModel` objects, not `RoomParticipant`. ↓
fix Convert to list: `rooms = list(rooms_client.list_rooms())` or use for-loop.
deprecated The `valid_from` and `valid_until` parameters in `create_room` and `update_room` have been deprecated in favor of setting `valid_from` and `valid_until` as datetime properties. Omitting them or passing None is fine, but using `valid_from` and `valid_until` differently may cause issues. ↓
fix Pass `valid_from` and `valid_until` as `datetime.datetime` objects in UTC or None.
gotcha The `add_participants`, `update_participants`, and `remove_participants` methods accept a list of `RoomParticipant` objects. For removal, you only need the `communication_identifier`; the `role` is ignored but must still be a valid enum value (use `ParticipantRole.PRESENTER` as placeholder). ↓
fix When removing, pass participants with any role but only identifier matters: `rooms_client.remove_participants(room_id, [RoomParticipant(communication_identifier='8:acs:...', role=ParticipantRole.PRESENTER)])`.
Install
pip install azure-identity azure-communication-rooms Imports
- RoomsClient wrong
from azure.communication.rooms._rooms_client import RoomsClientcorrectfrom azure.communication.rooms import RoomsClient - RoomParticipant wrong
from azure.communication.rooms.models import RoomParticipantcorrectfrom azure.communication.rooms import RoomParticipant - ParticipantRole wrong
from azure.communication.rooms._models import ParticipantRolecorrectfrom azure.communication.rooms import ParticipantRole
Quickstart
import os
from azure.communication.rooms import RoomsClient, RoomParticipant, ParticipantRole
from azure.identity import DefaultAzureCredential
# Use environment variable AZURE_COMMUNICATION_CONNECTION_STRING for connection string
# or use DefaultAzureCredential with endpoint.
# For simplicity, using a connection string (replace with actual).
endpoint = os.environ.get('AZURE_COMMUNICATION_ENDPOINT', '')
credential = DefaultAzureCredential()
rooms_client = RoomsClient(endpoint, credential)
# Create a room
room = rooms_client.create_room(
valid_from=None,
valid_until=None,
participants=[
RoomParticipant(
communication_identifier='8:acs:your-identifier', # replace
role=ParticipantRole.PRESENTER
)
]
)
print(f'Room created with ID: {room.id}')
# List rooms
rooms = rooms_client.list_rooms()
for r in rooms:
print(f'Room ID: {r.id}')
# Update room validity
updated = rooms_client.update_room(room_id=room.id, valid_from=None, valid_until=None)
print(f'Room updated: {updated.id}')
# Delete room
rooms_client.delete_room(room_id=room.id)