Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 1.82 KB

howto-create-serviceclient-with-python-and-azure-identity.md

File metadata and controls

62 lines (43 loc) · 1.82 KB
titledescriptionauthorms.authorms.datems.servicems.customms.topic
How to create a WebPubSubServiceClient with Python and Azure Identity
How to create a WebPubSubServiceClient with Python and Azure Identity
terencefan
tefa
11/15/2021
azure-web-pubsub
devx-track-python
how-to

How to create a WebPubSubServiceClient with Python and Azure Identity

This how-to guide shows you how to create a WebPubSubServiceClient using Microsoft Entra ID in Python.

Requirements

Sample codes

  1. Create a TokenCredential with Azure Identity SDK.

    fromazure.identityimportDefaultAzureCredentialcredential=DefaultAzureCredential()

    credential can be any class that inherits from TokenCredential class.

    • EnvironmentCredential
    • ClientSecretCredential
    • ClientCertificateCredential
    • ManagedIdentityCredential
    • VisualStudioCredential
    • VisualStudioCodeCredential
    • AzureCliCredential

    To learn more, see Azure Identity client library for Python

  2. Then create a client with endpoint, hub, and credential.

    fromazure.identityimportDefaultAzureCredentialcredential=DefaultAzureCredential() client=WebPubSubServiceClient(hub="<hub>", endpoint="<endpoint>", credential=credential)

    Learn how to use this client, see Azure Web PubSub service client library for Python

close