Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
How to create a
This how-to guide shows you how to create a WebPubSubServiceClient using Microsoft Entra ID in Python.
Requirements
Install azure-identity package from pypi.org.
python -m pip install azure-identityInstall azure-messaging-webpubsubservice package from pypi.org.
python -m pip install azure-messaging-webpubsubservice
Sample codes
Create a
TokenCredentialwith Azure Identity SDK.from azure.identity import DefaultAzureCredential credential = DefaultAzureCredential()credentialcan be any class that inherits fromTokenCredentialclass.- EnvironmentCredential
- ClientSecretCredential
- ClientCertificateCredential
- ManagedIdentityCredential
- VisualStudioCredential
- VisualStudioCodeCredential
- AzureCliCredential
To learn more, see Azure Identity client library for Python
Then create a
clientwithendpoint,hub, andcredential.from azure.identity import DefaultAzureCredential credential = DefaultAzureCredential() client = WebPubSubServiceClient(hub="<hub>", endpoint="<endpoint>", credential=credential)Learn how to use this client, see Azure Web PubSub service client library for Python