title | description | author | ms.author | ms.service | ms.topic | ms.date |
---|---|---|---|---|---|---|
Azure Web PubSub service data plane REST API reference overview |
Describes the REST APIs Azure Web PubSub supports to manage the WebSocket connections and send messages to them. |
vicancy |
lianwei |
azure-web-pubsub |
reference |
06/09/2022 |
As illustrated by the above workflow graph, and also detailed workflow described in internals, your app server can send messages to clients or to manage the connected clients using REST APIs exposed by Web PubSub service. This article describes the REST APIs in detail.
In each HTTP request, an authorization header with a JSON Web Token (JWT) is required to authenticate with Azure Web PubSub Service.
HS256
, namely HMAC-SHA256, is used as the signing algorithm.
You should use the AccessKey
in Azure Web PubSub Service instance's connection string to sign the generated JWT token.
Below claims are required to be included in the JWT token.
Claim Type | Is Required | Description |
---|---|---|
aud |
true | Should be the SAME as your HTTP request url. For example, a broadcast request's audience looks like: https://example.webpubsub.azure.com/api/hubs/myhub/:send?api-version=2022-11-01 . |
exp |
true | Epoch time when this token will be expired. |
A pseudo code in JS:
const bearerToken = jwt.sign({}, connectionString.accessKey, {
audience: request.url,
expiresIn: "1h",
algorithm: "HS256",
});
Like using AccessKey
, a JSON Web Token (JWT) is also required to authenticate the HTTP request.
The difference is, in this scenario, JWT Token is generated by Microsoft Entra ID.
Learn how to generate Microsoft Entra tokens
The credential scope used should be https://webpubsub.azure.com/.default
.
You could also use Role Based Access Control (RBAC) to authorize the request from your server to Azure Web PubSub Service.
Learn how to configure Role Based Access Control roles for your resource
Operation Group | Description |
---|---|
Service Status | Provides operations to check the service status |
Hub Operations | Provides operations to manage the connections and send messages to them. |