Registry /
azure / azure-messaging-webpubsubclient
Install & Compatibility
Where this runs
tested against v1.1.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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.562s · 24.1MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.5s · import 0.508s · 25MB
23MB installed
● package 23MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
WebPubSubClient
✓ from azure.messaging.webpubsubclient import WebPubSubClient
✗ from azure.messaging.webpubsub import WebPubSubClient
The package is azure-messaging-webpubsubclient, not azure-messaging-webpubsub.
WebPubSubClientCredential
✓ from azure.messaging.webpubsubclient.models import WebPubSubClientCredential
Wrong import path leads to ImportError.
Minimal setup to connect to Azure Web PubSub using a connection string.
import os
from azure.messaging.webpubsubclient import WebPubSubClient
from azure.messaging.webpubsubclient.models import WebPubSubClientCredential
connection_string = os.environ.get('WEBPUBSUB_CONNECTION_STRING', '')
client = WebPubSubClient(connection_string=connection_string)
client.open()
# ... use client
client.close()
Errors
Common errors & fixes
ImportError: cannot import name 'WebPubSubClient' from 'azure.messaging.webpubsub'
Incorrect import path; the correct package is azure.messaging.webpubsubclient.
fixUse: from azure.messaging.webpubsubclient import WebPubSubClient
AttributeError: 'WebPubSubClient' object has no attribute 'on'
The 'on' method was renamed to 'subscribe' in version 1.0.0.
fixUse client.subscribe(event, handler) instead.
TypeError: __init__() got an unexpected keyword argument 'credential'
The constructor expects either 'connection_string' or 'credential' as a WebPubSubClientCredential object, not a raw credential.
fixCreate a WebPubSubClientCredential object first: from azure.messaging.webpubsubclient.models import WebPubSubClientCredential; credential = WebPubSubClientCredential(...); client = WebPubSubClient(credential=credential)
Upgrade
Version history
1.1.0latest on PyPI · released May 6, 2024
Audit
Dependencies
azure-corerequiredRequired for core Azure SDK functionality (policies, credentials)
websocket-clientrequiredUsed for WebSocket connections
azure-identityoptionalFor authentication using DefaultAzureCredential or other credential types