Cloud service · Azure · Updated

Azure Web PubSub - Azure Web PubSub is a managed service for real-time, bidirectional messaging over WebSockets using publish-subscribe patterns.

In short

Azure Web PubSub manages persistent client connections and message fan-out for web, mobile, and other connected applications. Applications use hubs, groups, users, and events to route updates while retaining control over authentication, business logic, and persistence. It also offers a Socket.IO development experience and preview support for a subset of MQTT over WebSocket.

Cloud Services Hub →

9 key features of Azure Web PubSub

01
Managed WebSocket connections

Maintain persistent client connections without operating a WebSocket server fleet. Backend workers and APIs can scale separately from connected clients.

02
Targeted message routing

Send messages to all connections in a hub, a group, a user, or a specific connection. Use groups for application audiences such as document collaborators or subscribers to a particular asset.

03
Authorized client publish-subscribe

Clients using supported subprotocols can join groups and publish directly when their access tokens grant the necessary permissions. Limit these permissions to authorized audiences, and route sensitive operations through application handlers.

04
Upstream event handlers

Forward configured connection and client events to application HTTP endpoints or Azure Functions. Use handlers to validate incoming actions, apply business rules, and coordinate downstream work.

05
Socket.IO support

The dedicated Socket.IO capability manages connection infrastructure and coordination across application servers. It preserves the Socket.IO programming model while reducing the infrastructure required for multi-server deployments.

06
MQTT over WebSocket in preview

Connect MQTT clients over WebSocket and exchange supported messages with native Web PubSub clients. This is a limited protocol adaptation: wildcard subscriptions, retained messages, shared subscriptions, and topic aliases are not supported.

07
Identity and network controls

Use Microsoft Entra ID and Azure RBAC for supported backend operations, and apply private endpoints and network access rules to restrict exposure. Client connections still require an application-designed authentication and authorization flow.

08
Premium scaling and resilience

Premium supports metric-based or scheduled autoscale, zone redundancy in supported regions, and geo-replication. Size deployments against both connection demand and messaging workload, and implement client recovery for disruptions.

09
Operational visibility

Service metrics expose connection counts, quota utilization, server load, traffic, and request outcomes. Use diagnostic logs and development tracing to investigate failed connections, authorization errors, and message-routing problems.

Where Azure Web PubSub is used

  1. 01
    Live operational dashboards

    Push equipment status, financial indicators, or workflow changes to browsers subscribed to relevant groups. Load an authoritative snapshot through an API before applying incremental updates.

  2. 02
    Collaborative applications

    Distribute cursor movement, presence signals, and document-change notifications to participants in a shared session. Keep conflict resolution, durable document state, and access checks in the application.

  3. 03
    Chat and session messaging

    Use groups to distribute messages among participants and user targeting to notify all of a user's connected devices. When using the base service, implement membership policy, moderation, and durable history in the backend.

  4. 04
    User-specific notifications

    Deliver job completion, order status, or approval updates to connected users without polling. Persist notifications separately when users must see updates received while offline.

  5. 05
    Multiplayer coordination

    Exchange lobby changes, turn updates, and room-level game events. Keep authoritative game rules on trusted compute and benchmark latency and throughput against the game's requirements.

  6. 06
    AI response streaming

    Relay generated text fragments and progress events from backend inference workflows to an authorized client or conversation group. Include request identifiers and cancellation handling so clients can distinguish concurrent responses.

How Azure Web PubSub is priced

Free tier

A limited-capacity tier supports development, evaluation, and small experiments within its connection and messaging allowances. It is not intended to provide production availability guarantees.

Standard tier

Paid capacity is provisioned in units, with connection capacity and included messaging allowances determined by the selected SKU and unit count. Outbound messaging above the included allowance is billed according to the applicable rate; fan-out and message size affect metered message volume.

Premium tier

Premium uses paid provisioned capacity and messaging meters while adding capabilities such as autoscale, zone redundancy in supported regions, and geo-replication. Budget for the configured capacity of each replica and check regional SKU availability, quotas, and rates before deployment.

Services Azure Web PubSub works with

A common architecture places an authenticated API in Azure App Service or Azure Functions in front of the connection-establishment flow. The API checks application permissions and returns a short-lived client access URL. Clients then connect directly to Web PubSub, while backend services publish through SDKs or REST APIs. Configured upstream handlers receive client events that require server-side validation or processing.

For event-driven applications, retain durable processing in services such as Azure Service Bus and use a consumer to translate business events into targeted live notifications. Event Hubs consumers can aggregate telemetry before publishing dashboard updates. Cosmos DB can hold authoritative state and history, with a change feed processor announcing committed changes. These are application-mediated integrations rather than automatic delivery guarantees across services.

Design reconnect behavior around a snapshot API or durable history store, because live delivery alone does not synchronize clients that were offline. Include identifiers and versions in updates so clients can reconcile state. Use managed identities and appropriate roles for backend access where supported, and monitor both Web PubSub and its application dependencies through Azure Monitor. Scale message-processing compute independently from connection capacity, and test the complete path under fan-out peaks.

Azure Functions

Use Azure Functions bindings and triggers to issue client access information, handle Web PubSub events, and publish messages. For example, an authenticated HTTP function can authorize a dashboard subscription while a queue-triggered function sends job progress to the user's connections. Keep callback processing short and move lengthy work to asynchronous processing.

App Service

Host the application API and negotiation endpoint in App Service while clients maintain their WebSocket connections directly with Web PubSub. For example, an order-management API can validate a user's access and publish order changes through the service SDK. A managed identity with an appropriate Web PubSub data-plane role can reduce reliance on stored service keys.

Service Bus

Use a backend consumer to translate durable Service Bus messages into real-time client updates. For example, a worker can consume an OrderShipped event and notify the corresponding user's active sessions. Service Bus supplies durable backend delivery; Web PubSub supplies live fan-out, so retain a separate state or notification store for offline clients.

Event Hubs

Process streaming events with a consumer application and publish selected or aggregated results to Web PubSub groups. For example, a telemetry processor can summarize sensor readings per facility and update subscribed dashboards once per second. Avoid forwarding an entire high-volume stream to every client without filtering, aggregation, and capacity testing.

Azure Cosmos DB

Store authoritative application state or message history in Cosmos DB and use a change feed processor to publish committed changes. For example, a processor can notify a project group when a task document changes. Include document versions or event identifiers so clients can reconcile repeated or out-of-order application updates.

Azure Monitor

Create Azure Monitor alerts for connection utilization, server load, and request failures, and send supported diagnostic logs to a Log Analytics workspace. For example, alert before connection capacity is exhausted and correlate failed client connections with backend negotiation errors. Premium deployments can also use Azure Monitor autoscale rules to adjust capacity.

API Management

Azure Web PubSub can serve as the backend for an API Management WebSocket API. API Management applies configured policies to the initial HTTP handshake and then proxies the established WebSocket connection to Web PubSub.

Azure Application Gateway

Azure Web PubSub can receive client WebSocket connections through Application Gateway. The gateway can forward traffic to a Web PubSub private endpoint, so clients can connect through the gateway while public network access to Web PubSub is disabled.

Azure Blob Storage

Azure Web PubSub can archive connectivity, messaging, and HTTP request logs in Blob Storage through its diagnostic settings. For example, you can retain connect and disconnect records for later troubleshooting.

Azure DNS

Azure Web PubSub private endpoints can use the Azure Private DNS zone `privatelink.webpubsub.azure.com`. Clients in linked virtual networks can then use the normal Web PubSub hostname and resolve it to the private endpoint's IP address.

Alternatives to Azure Web PubSub in other clouds

AWS

Amazon API GatewayAmazon API Gateway

Both services manage WebSocket connections for real-time, two-way communication. Amazon API Gateway also publishes HTTP and REST APIs and bills WebSocket usage by messages and connection minutes, while Azure Web PubSub focuses on publish-subscribe messaging and bills paid tiers for provisioned capacity and metered messaging.

Compare fact by fact
Azure Web PubSubAmazon API Gateway
Service scopeWebSocket publish-subscribe messagingHTTP, REST, and WebSocket APIs
Paid WebSocket billingCapacity units and metered messagingMessages and connection minutes
Automatic scalingAutoscale on PremiumAutomatic with incoming traffic
AWS AppSyncAWS AppSync

AppSync Events, part of AWS AppSync, and Azure Web PubSub both provide managed WebSocket publish-subscribe messaging. AppSync Events bills for API operations and connection minutes, while Azure Web PubSub’s paid tiers bill for provisioned capacity and meter messaging.

Compare fact by fact
Azure Web PubSubAWS AppSync
Paid billing modelProvisioned units and messagingAPI operations and connection minutes
Compared Nov 2026

What is Azure Web PubSub

2 min read

Azure Web PubSub separates long-lived client connections from application processing. Clients connect directly to the service over WebSockets, while application servers use service SDKs or REST APIs to send messages and manage connections. This architecture lets application compute scale independently from the infrastructure maintaining connected browsers and devices. It is useful when applications need immediate updates rather than repeated HTTP polling.

The base service organizes connections into hubs. Each connection belongs to one hub, and groups within that hub identify subsets of connections that should receive the same messages. A user identifier can associate multiple connections with one application user, such as connections from several browser tabs or devices. Use a small, predetermined set of hubs for application scenarios and groups for dynamic audiences such as projects, sessions, or dashboard subscriptions. Hubs and groups are routing constructs, not substitutes for application authorization.

A typical connection flow starts at an authenticated application endpoint. The backend validates the caller and issues a short-lived client access URL containing a token scoped to the required hub, user, and permissions. The client then connects directly to Web PubSub. Keep service access keys and connection strings on trusted servers, never in browser code. Backend applications can use Microsoft Entra ID credentials and Azure role-based access control for supported service operations instead of distributing shared keys.

Applications can send to an entire hub, a group, a user, or an individual connection. With an appropriate subprotocol and permissions, clients can publish directly to groups without routing every message through application compute. When validation or business processing is required, configure upstream event handlers to receive client events through HTTP callbacks. Account for callback authentication, response time, and failure handling when designing these handlers.

The base service provides real-time transport rather than a durable event log or application database. Store authoritative state and message history separately, and define how clients obtain a fresh snapshot after a disconnect. Supported reliable client protocols provide bounded connection recovery, but this does not replace durable replay. Use application sequence numbers, idempotent processing, and state reconciliation where missed or repeated updates would affect correctness.

Choose capacity using concurrent connections, message sizes, fan-out, and measured server load rather than connection count alone. Premium supports autoscale, zone redundancy in supported regions, and geo-replication. Monitor utilization and connection failures, and test reconnect behavior during scaling and regional disruption. Socket.IO applications should use the dedicated Socket.IO capability rather than assume wire compatibility with the base WebSocket endpoint. MQTT support remains a preview adaptation over WebSocket and does not provide a complete MQTT broker.

Azure architecture icons are the property of Microsoft. BlowStack is not affiliated with or endorsed by Microsoft.

AWS architecture icons are the property of Amazon Web Services. BlowStack is not affiliated with or endorsed by AWS.