Azure Web PubSub samples - Authenticate and connect

To make use of your Azure Web PubSub resource, you need to authenticate and connect to the service first. Azure Web PubSub service distinguishes two roles and they're given a different set of capabilities.

Client

The client can be a browser, a mobile app, an IoT device or even an EV charging point as long as it supports WebSocket. A client is limited to publishing and subscribing to messages.

Application server

While the client's role is often limited, the application server's role goes beyond simply receiving and publishing messages. Before a client tries to connect with your Web PubSub resource, it goes to the application server for a Client Access Token first. The token is used to establish a persistent WebSocket connection with your Web PubSub resource.

Use case Description
Using connection string Applies to application server only.
Using Client Access Token Applies to client only. Client Access Token is generated on the application server.
Using Microsoft Entra ID Using Microsoft Entra ID for authorization offers improved security and ease of use compared to Access Key authorization.
Anonymous connection Anonymous connection allows clients to connect with Azure Web PubSub directly without going to an application server for a Client Access Token first. This is useful for clients that have limited networking capabilities, like an EV charging point.
Use case Description
Using connection string Applies to application server only.
Using Client Access Token Applies to client only. Client Access Token is generated on the application server.
Using Microsoft Entra ID Using Microsoft Entra ID for authorization offers improved security and ease of use compared to Access Key authorization.
Use case Description
Using connection string Applies to application server only.
Using Client Access Token Applies to client only. Client Access Token is generated on the application server.
Using Microsoft Entra ID Using Microsoft Entra ID for authorization offers improved security and ease of use compared to Access Key authorization.
Use case Description
Using connection string Applies to application server only.
Using Client Access Token Applies to client only. Client Access Token is generated on the application server.
Using Microsoft Entra ID Using Microsoft Entra ID for authorization offers improved security and ease of use compared to Access Key authorization.