Registry / azure / azure-communication-rooms

azure-communication-rooms

JSON →
library1.2.0pypypi✓ verified 85d ago

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
INSTALL
IMPORT
SIG · AZURE-COMMUNICATIO
A
azure-communication-rooms
azurepythonv1.2.0
Install
3.1s avg
Import
416ms
Disk
41MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.433s · 42.6MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.1s · import 0.399s · 43MB
41MB installed
● package 41MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RoomsClient
from azure.communication.rooms import RoomsClient
from azure.communication.rooms._rooms_client import RoomsClient
Private underscored modules should not be imported directly; use the public API.
RoomParticipant
from azure.communication.rooms import RoomParticipant
from azure.communication.rooms.models import RoomParticipant
RoomParticipant is exposed at package level; the .models submodule is considered private.
ParticipantRole
from azure.communication.rooms import ParticipantRole
from azure.communication.rooms._models import ParticipantRole
Use the public package-level export, not private module.

Authenticate, create a room, list rooms, update, and delete. Replace the identifier and endpoint with your Azure Communication Services resource details.

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)
Debug
Known issues
gotchaDo 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
affects: all
gotchaThe `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`.
affects: all
breakingIn 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.
affects: >=1.1.0
deprecatedThe `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.
affects: <=1.2.0
gotchaThe `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)])`.
affects: all
Errors
Common errors & fixes
'RoomsClient' object has no attribute 'create_room'
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`
AttributeError: module 'azure.communication.rooms' has no attribute 'RoomParticipant'
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`
ValueError: Invalid role. Valid roles are: Attendee, Consumer, Presenter
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).
HttpResponseError: (BadRequest) Participant identifier is not valid.
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.
ModuleNotFoundError: No module named 'azure.communication'
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.
Upgrade
Version history
1.2.0latest on PyPI · released Mar 19, 2025
Audit
Dependencies
azure-corerequiredRequired for HTTP pipeline and authentication
azure-identityoptionalRecommended for obtaining credentials (DefaultAzureCredential, etc.)
Agent activity
38 hits · last 30 days
node
34
OpenAI (training)
1
Resources