| name | azure-messaging-webpubsubservice-py |
| description | Azure Web PubSub Service SDK for Python. Use for real-time messaging, WebSocket connections, and pub/sub patterns. |
| type | skill |
| created | 2026-02-27T00:00:00.000Z |
| domain | cloud-infrastructure |
| category | azure |
| risk | unknown |
| source | community |
| tags | ["skill","cloud-infrastructure","azure","messaging","webpubsubservice"] |
Azure Web PubSub Service SDK for Python
Real-time messaging with WebSocket connections at scale.
Installation
pip install azure-messaging-webpubsubservice
pip install azure-messaging-webpubsubclient
Environment Variables
AZURE_WEBPUBSUB_CONNECTION_STRING=Endpoint=https://<name>.webpubsub.azure.com;AccessKey=...
AZURE_WEBPUBSUB_HUB=my-hub
Service Client (Server-Side)
Authentication
from azure.messaging.webpubsubservice import WebPubSubServiceClient
client = WebPubSubServiceClient.from_connection_string(
connection_string=os.environ["AZURE_WEBPUBSUB_CONNECTION_STRING"],
hub="my-hub"
)
from azure.identity import DefaultAzureCredential
client = WebPubSubServiceClient(
endpoint="https://<name>.webpubsub.azure.com",
hub="my-hub",
credential=DefaultAzureCredential()
)
Generate Client Access Token
token = client.get_client_access_token()
print(f"URL: {token['url']}")
token = client.get_client_access_token(
user_id="user123",
roles=["webpubsub.sendToGroup", "webpubsub.joinLeaveGroup"]
)
token = client.get_client_access_token(
user_id="user123",
groups=["group1", "group2"]
)
Send to All Clients
client.send_to_all(message="Hello everyone!", content_type="text/plain")
client.send_to_all(
message={: , : },
content_type=
)