azure-messaging-webpubsubservice-py

Solid

Azure Web PubSub Service SDK for Python. Use for real-time messaging, WebSocket connections, and pub/sub patterns. Triggers: "azure-messaging-webpubsubservice", "WebPubSubServiceClient", "real-time", "WebSocket", "pub/sub".

Web & Frontend 2,541 stars 295 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 96/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Azure Web PubSub Service SDK for Python Real-time messaging with WebSocket connections at scale. ## Installation ```bash # Service SDK (server-side) pip install azure-messaging-webpubsubservice # Client SDK (for Python WebSocket clients) pip install azure-messaging-webpubsubclient ``` ## Environment Variables ```bash AZURE_WEBPUBSUB_CONNECTION_STRING=Endpoint=https://<name>.webpubsub.azure.com;AccessKey=... AZURE_WEBPUBSUB_HUB=my-hub ``` ## Service Client (Server-Side) ### Authentication ```python from azure.messaging.webpubsubservice import WebPubSubServiceClient # Connection string client = WebPubSubServiceClient.from_connection_string( connection_string=os.environ["AZURE_WEBPUBSUB_CONNECTION_STRING"], hub="my-hub" ) # Entra ID from azure.identity import DefaultAzureCredential client = WebPubSubServiceClient( endpoint="https://<name>.webpubsub.azure.com", hub="my-hub", credential=DefaultAzureCredential() ) ``` ### Generate Client Access Token ```python # Token for anonymous user token = client.get_client_access_token() print(f"URL: {token['url']}") # Token with user ID token = client.get_client_access_token( user_id="user123", roles=["webpubsub.sendToGroup", "webpubsub.joinLeaveGroup"] ) # Token with groups token = client.get_client_access_token( user_id="user123", groups=["group1", "group2"] ) ``` ### Send to All Clients ```python # Send text client.send_to_all(message="Hello everyone!", content_type="text/plain") # ...

Details

Author
microsoft
Repository
microsoft/skills
Created
4 months ago
Last Updated
yesterday
Language
TypeScript
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category