AZ-204Chapter 18 of 102Objective 5.3

Azure SignalR Service for Real-Time Apps

This chapter covers Azure SignalR Service, a managed service for adding real-time web functionality to applications. Real-time features such as live dashboards, chat, notifications, and collaborative editing are critical for modern user experiences. On the AZ-204 exam, this topic appears in the 'Integrate' domain (objective 5.3) and typically accounts for 5-10% of questions. You must understand how SignalR Service simplifies WebSocket management, scaling, and authentication, and how it integrates with Azure Functions, App Service, and other services.

25 min read
Intermediate
Updated May 31, 2026

SignalR as a Radio Station with Two-Way Talkback

Imagine a radio station that broadcasts music to thousands of listeners. That's the traditional HTTP model: one-way, server-to-client. But Azure SignalR Service is like a radio station that also has a talkback channel: each listener's radio has a microphone button. When a listener presses the button, they speak directly to the station, and the station can instantly rebroadcast that message to all other listeners (or a specific group). The station doesn't own the physical radios; it provides the infrastructure for the two-way communication. In this analogy, the radio waves are the persistent WebSocket connections. The station's control room (SignalR Service) manages who is listening, which groups they belong to, and how to route messages. When a listener changes the channel (joins a group), the station updates its routing table. If a listener's radio goes out of range (connection drops), the station attempts to re-establish contact using a fallback mechanism (like FM/AM switching – in SignalR, it's automatic transport negotiation from WebSocket to Server-Sent Events to long polling). The station also scales: to serve a city of millions, you have multiple broadcast towers (SignalR units) that share the audience load. Without this service, each radio station would have to build its own two-way infrastructure, which is complex and costly. SignalR Service abstracts the complexity, letting developers focus on the content (messages) rather than the physics of radio waves (connection management).

How It Actually Works

What is Azure SignalR Service and Why It Exists

Azure SignalR Service is a fully managed Platform-as-a-Service (PaaS) that simplifies adding real-time web functionality to applications. Real-time means the server can push content to connected clients instantly without the client polling. The underlying technology is ASP.NET Core SignalR, an open-source library that abstracts WebSockets, Server-Sent Events (SSE), and long polling. However, hosting SignalR yourself requires managing persistent connections, scaling out across multiple servers (backplane), and handling connection drops. Azure SignalR Service removes that burden by acting as a proxy between clients and your application server.

How It Works Internally

Azure SignalR Service uses a negotiation process to establish a persistent connection. The client first sends an HTTP request to the application server's /negotiate endpoint. The server responds with a URL pointing to the SignalR Service endpoint, including an access token. The client then opens a WebSocket (or fallback transport) directly to the SignalR Service. From that point, all messages between client and server flow through the SignalR Service, which handles routing, broadcasting, and scaling.

The service operates as a message broker. It maintains a mapping of connections (connectionId) to groups and users. When a server wants to send a message, it calls the SignalR Service's REST API or uses the SignalR SDK, and the service delivers the message to the appropriate clients. This decouples the server from direct client connections, allowing the server to scale independently.

Key Components, Values, Defaults, and Timers

Transport Types: WebSocket (default, most efficient), Server-Sent Events (SSE), and Long Polling. The client negotiates the best available transport in that order. WebSocket requires the Sec-WebSocket-Protocol header.

Connection Lifetime: Default idle timeout is 30 minutes on the service side. If no data is sent for 30 minutes, the service may close the connection. Clients should implement reconnection logic.

Hub: A class in the application that handles client-server communication. Each hub has methods that clients can call, and the hub can call methods on clients.

Groups: Logical sets of connections. Clients can join or leave groups. Messages can be sent to a specific group, enabling features like chat rooms.

Users: Authenticated users are identified by a user identifier (typically the user ID from authentication). Messages can be sent to a specific user across multiple connections.

Scale Units: Each SignalR Service instance has a number of units that determine capacity. One unit supports 1,000 concurrent connections and 1 million messages per day (default). You can scale up to 100 units per instance (100,000 connections).

Serverless Mode: When using Azure Functions, you can use SignalR Service in serverless mode. The service handles client connections, and the function app triggers on messages. No application server is needed.

Authentication: Supports Azure Active Directory, Access Keys, and Managed Identity. The access token is a JWT token generated by the application server during negotiation.

Configuration and Verification Commands

To create a SignalR Service instance via Azure CLI:

az signalr create --name mysignalr --resource-group myrg --sku Standard_S1 --unit-count 1 --service-mode Default

The --service-mode can be Default (requires an app server), Serverless (no app server), or Classic (supports both but has limitations).

To get connection strings:

az signalr key list --name mysignalr --resource-group myrg

To test connectivity from a client, use the SignalR CLI tool or a simple JavaScript client. For example, in a browser console:

const connection = new signalR.HubConnectionBuilder()
    .withUrl("https://mysignalr.service.signalr.net/client/?hub=chat")
    .build();
connection.on("ReceiveMessage", (user, message) => console.log(user, message));
connection.start();

How It Interacts with Related Technologies

Azure App Service: You deploy your SignalR hub application to App Service. The app server handles negotiation and authentication. SignalR Service manages the persistent connections. This offloads the WebSocket handling from App Service, which has a limited number of concurrent WebSocket connections (default 50 per instance, can be increased).

Azure Functions: In serverless mode, the function app uses SignalR bindings to send messages. The SignalRConnectionInfo input binding generates the negotiation endpoint. The SignalR output binding sends messages to clients.

Azure API Management: You can expose SignalR endpoints through API Management for security, throttling, and transformation.

Azure Redis Cache: Not directly related, but if you were hosting SignalR yourself, you would need a Redis backplane for scaling. With SignalR Service, the backplane is managed for you.

Message Flow Example

1.

Client sends HTTP GET to https://myapp.azurewebsites.net/chat/negotiate.

2.

App server validates authentication, generates a JWT token with endpoint URL and access key, and returns { "url": "https://mysignalr.service.signalr.net/client/?hub=chat", "accessToken": "..." }.

3.

Client opens WebSocket to the provided URL with the token.

4.

SignalR Service accepts the connection, assigns a connectionId, and adds the client to the default group (or specified groups).

5.

When server wants to broadcast, it calls hubContext.Clients.All.SendAsync("ReceiveMessage", "Hello"). The SDK sends a POST request to SignalR Service's REST API with the message payload.

6.

SignalR Service forwards the message to all connected clients in the target group.

Scaling and Performance

Concurrent Connections: Each unit supports 1,000 concurrent connections. You can scale up to 100 units. For more connections, you can have multiple SignalR Service instances behind a load balancer, but clients must be routed to the correct instance (sticky sessions).

Messages per Day: 1 million per unit per day. This is a soft limit; you can request increases.

Throughput: Each unit can handle approximately 1,000 messages per second (varies by message size).

Latency: Typically under 100ms for WebSocket messages within the same region.

Security

Access Keys: Two keys (primary and secondary) are provided. Used to sign JWT tokens. Rotate keys regularly.

Managed Identity: SignalR Service can use a managed identity to access other Azure resources (e.g., Key Vault for secrets).

Private Endpoints: You can use Azure Private Link to keep traffic within your virtual network.

CORS: Configure allowed origins for browser clients.

Monitoring

Metrics: Connection count, message count, connection errors, etc. Available in Azure Monitor.

Logs: Diagnostic settings can send logs to Log Analytics, Storage, or Event Hubs. Logs include connection events, errors, and message traces.

Alerts: Set alerts on metrics like high connection error rate or approaching connection limit.

Pricing

Free Tier: 20 concurrent connections, 20,000 messages per day. Not for production.

Standard Tier: Pay per unit. Standard_S1 is the most common. Pricing includes a certain number of messages and connections. Additional messages are charged per million.

Walk-Through

1

Create SignalR Service Instance

In the Azure portal, search for 'SignalR Service' and click 'Create'. Fill in subscription, resource group, resource name (globally unique), region (choose close to users), pricing tier (Standard_S1 for production), unit count (start with 1), and service mode (Default if you have an app server, Serverless if using Azure Functions). Review and create. This takes about 1-2 minutes. After creation, note the connection string and endpoint URL from the 'Keys' blade.

2

Configure Application Server

Add the SignalR SDK to your ASP.NET Core application. Install NuGet package 'Microsoft.Azure.SignalR'. In Program.cs, add `builder.Services.AddSignalR().AddAzureSignalR(connectionString);`. Configure the hub endpoints. For example, map the '/chat' hub in the endpoint routing: `app.MapHub<ChatHub>("/chat");`. The application server now handles negotiation and authentication. Ensure the server is publicly accessible (e.g., deployed to Azure App Service).

3

Implement Client Connection

On the client side (e.g., JavaScript), include the SignalR client library. Create a HubConnectionBuilder, call withUrl() pointing to the application server's hub endpoint (e.g., 'https://myapp.azurewebsites.net/chat'). The client will automatically negotiate and then connect to the SignalR Service. Implement reconnection policy using .withAutomaticReconnect() to handle drops. Start the connection with .start(). Register event handlers with .on() to receive messages.

4

Send Messages from Server

To send messages from the server to clients, inject IHubContext<ChatHub> into your services. Use methods like `Clients.All.SendAsync("ReceiveMessage", user, message)` to broadcast, `Clients.Group(groupName).SendAsync(...)` to send to a group, or `Clients.User(userId).SendAsync(...)` to send to a specific user. The SDK automatically calls the SignalR Service REST API to deliver the message. No direct client connection is needed on the server.

5

Scale and Monitor

As traffic grows, increase the unit count in the SignalR Service scale blade. You can also enable autoscaling based on metrics like connection count. Monitor using Azure Monitor metrics: track connection count, message count, and errors. Set up diagnostic logs to capture connection events for troubleshooting. For high availability, deploy instances in multiple regions and use Traffic Manager or Front Door to route users to the nearest instance.

What This Looks Like on the Job

Enterprise Scenario 1: Live Dashboard for Financial Trading

A financial services company needs a real-time dashboard showing stock prices, portfolio values, and alerts. The application is an ASP.NET Core web app hosted on Azure App Service. They use Azure SignalR Service to push price updates to thousands of traders. The server receives price feeds from a third-party API and broadcasts updates to all connected clients every second. With SignalR Service, they avoid the complexity of managing WebSocket connections at scale. They configured 10 units to support 10,000 concurrent connections. The system handles 5 million messages per day. The key challenge was authentication: they used Azure AD to authenticate traders and passed the user ID to SignalR Service to ensure only authorized users receive sensitive data. They also implemented private endpoints to keep traffic within their virtual network. Misconfiguration: Initially, they set the service mode to 'Serverless' but still had an app server, causing negotiation failures. They corrected it to 'Default'.

Enterprise Scenario 2: Multiplayer Game Notifications

A gaming company uses Azure Functions with SignalR Service in serverless mode to send real-time notifications to players when friends come online or when game invites are sent. The function app processes events from a queue and uses the SignalR output binding to push messages. They chose serverless mode because they have no persistent app server; the function app scales to zero when idle. The service handles 100,000 concurrent players during peak hours. They use groups to manage game rooms: each game has a unique group, and players join the group when they enter the game. When a player makes a move, the function sends the update to the group. The challenge was managing group membership: they had to ensure players leave the group when they disconnect. They implemented a disconnect event handler using the SignalR Service's OnDisconnectedAsync endpoint in a function. Misconfiguration: They forgot to set the HubName property in the function's SignalR attribute, causing messages not to be delivered. They fixed it by specifying the exact hub name (e.g., [SignalR(HubName = "game")]).

Enterprise Scenario 3: Collaborative Document Editing

A SaaS company provides a collaborative document editor similar to Google Docs. They use Azure SignalR Service to broadcast changes to all collaborators in real-time. Each document is a group. When a user types, the server broadcasts the delta to the group. They use the 'Default' service mode with an ASP.NET Core server that handles conflict resolution. The system supports 50,000 concurrent connections across 50 units. They implemented a custom reconnection policy with exponential backoff to handle network drops gracefully. The biggest issue they faced was message ordering: because SignalR Service does not guarantee order for messages sent from different servers, they had to implement a sequencer on the server side. They also used the AddAzureSignalR overload that allows setting ServerStickyMode to Required to ensure all messages from a client go to the same server. Misconfiguration: They initially set ServerStickyMode to Disabled, causing clients to reconnect to different servers and losing state. They changed it to Required after understanding the mechanism.

How AZ-204 Actually Tests This

What AZ-204 Tests on This Topic

Objective 5.3: 'Develop for real-time apps using Azure SignalR Service.' The exam tests your ability to:

Choose the appropriate service mode (Default, Serverless, Classic) based on the application architecture.

Configure authentication and authorization for SignalR connections.

Scale the service appropriately (unit count, connection limits).

Integrate SignalR Service with Azure Functions using bindings.

Understand transport negotiation and fallback mechanisms.

Common Wrong Answers and Why Candidates Choose Them

1.

Choosing 'Classic' mode when 'Default' is needed: Candidates see 'Classic' and think it supports both, so it must be better. But 'Classic' has limitations: it requires the app server to be always on and can cause issues with serverless functions. The exam expects you to choose 'Default' when you have an app server, and 'Serverless' when using Azure Functions.

2.

Thinking SignalR Service replaces the app server entirely: In 'Default' mode, the app server is still required for negotiation and authentication. Candidates think the service handles everything, but the server must still be present to generate tokens and handle hub logic.

3.

Assuming WebSocket is always used: The exam might ask about fallback transports. Candidates forget that if WebSocket fails, SignalR falls back to SSE, then long polling. They assume WebSocket is mandatory.

4.

Misunderstanding group vs. user: Questions may ask how to send a message to a specific logged-in user across multiple devices. Candidates might choose 'Send to group' but groups are logical sets you manage; 'Send to user' is built-in and works across connections with the same user ID.

Specific Numbers and Terms That Appear on the Exam

Default unit capacity: 1,000 concurrent connections per unit.

Default message limit: 1 million messages per unit per day.

Negotiation endpoint: /negotiate (implicitly created by the SDK).

Service modes: Default, Serverless, Classic.

Transport negotiation order: WebSocket -> Server-Sent Events -> Long Polling.

Azure Functions bindings: SignalRConnectionInfo (input) and SignalR (output).

Authentication: Access Key, Azure AD, Managed Identity.

Edge Cases and Exceptions

Serverless mode with multiple functions: If you have multiple function apps, they can all use the same SignalR Service instance, but each function must specify the hub name.

Connection string rotation: When you regenerate a key, existing connections remain valid until they disconnect. New connections use the new key.

Cross-origin requests: If the client is on a different domain, you must configure CORS on the SignalR Service (not just the app server).

Private endpoints: If using Private Link, the client must be on the same virtual network; otherwise, connection fails.

How to Eliminate Wrong Answers

If the question mentions 'no app server' or 'serverless', eliminate options that require an app server.

If the question asks about scaling, look for answers that mention unit count and connection limits.

If the question involves authentication, check whether the answer uses access keys or Azure AD appropriately.

If the question is about message delivery, remember that groups are for logical sets, users are for individuals.

Key Takeaways

Azure SignalR Service is a managed service that handles WebSocket connections, scaling, and message routing for real-time apps.

In Default mode, an app server is required for negotiation; in Serverless mode, Azure Functions provide the server logic.

Each unit supports 1,000 concurrent connections and 1 million messages per day (Standard tier).

Transport negotiation order: WebSocket → Server-Sent Events → Long Polling.

Use `Clients.User(userId)` to send to a specific authenticated user across multiple connections.

Authentication can be done via access keys, Azure AD, or managed identity; the negotiation endpoint returns a JWT token.

For high availability, deploy multiple SignalR Service instances in different regions and use Azure Traffic Manager.

Always implement reconnection logic on the client using `.withAutomaticReconnect()` to handle transient failures.

Private endpoints (Azure Private Link) keep traffic within your virtual network for security.

The `/negotiate` endpoint is automatically created by the SDK; you can customize it via the `MapHub` configuration.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

Azure SignalR Service (Default Mode)

Fully managed PaaS; no infrastructure to manage.

Automatic scaling up to 100,000 connections per instance.

Built-in transport negotiation and reconnection.

Integrated with Azure Monitor for metrics and logs.

Supports serverless mode with Azure Functions.

Self-Hosted SignalR with Redis Backplane

Requires managing VMs or containers for the SignalR server.

Must set up and scale Redis cache for backplane (e.g., 2 nodes for HA).

Manual implementation of fallback transports and reconnection logic.

Need to configure custom monitoring and alerting.

More control over the environment but higher operational overhead.

Watch Out for These

Mistake

Azure SignalR Service requires WebSocket; if WebSocket is blocked, it won't work.

Correct

SignalR automatically negotiates the best available transport. If WebSocket fails, it falls back to Server-Sent Events (SSE) and then long polling. This is handled by the client SDK, no extra configuration needed.

Mistake

In Default mode, the SignalR Service replaces the application server entirely.

Correct

In Default mode, the application server is still required for the `/negotiate` endpoint, authentication, and hub logic. The service only manages the persistent connections and message routing. The server must be running to accept negotiation requests.

Mistake

You can send messages to a specific user by using groups with the user's name as the group name.

Correct

While you could do that, SignalR Service has built-in user support via `Clients.User(userId)`. This automatically targets all connections associated with that user ID across multiple devices. Using groups requires manual management and is error-prone.

Mistake

Serverless mode means no server code is needed at all.

Correct

Serverless mode still requires server code (Azure Functions) to handle negotiation and message sending. The 'serverless' term means no persistent app server; the function app runs on-demand. The SignalR Service itself still needs the function to generate connection info.

Mistake

The Classic service mode is the best choice because it supports both server and serverless.

Correct

Classic mode has limitations: it requires the app server to be always on and can cause issues with serverless functions. Microsoft recommends using Default or Serverless explicitly. Classic is only for migration scenarios.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the difference between Default, Serverless, and Classic service modes?

Default mode requires an application server to handle negotiation and hub logic; the SignalR Service manages connections. Serverless mode is for use with Azure Functions; no persistent app server is needed. Classic mode supports both but has limitations and is intended for migration. For new projects, choose Default if you have an app server, Serverless if using Functions.

How do I authenticate clients with Azure SignalR Service?

Authentication is handled during negotiation. The client calls your app server's `/negotiate` endpoint, which validates the user (e.g., via cookies, JWT, or Azure AD) and then generates a signed JWT token containing the SignalR Service endpoint. The client uses this token to connect directly to the SignalR Service. You can also use access keys directly, but that is less secure.

Can I send a message to a specific user without knowing their connection ID?

Yes, use `Clients.User(userId).SendAsync(...)`. The userId is typically the authenticated user's ID. SignalR Service tracks all connections associated with that user and delivers the message to all of them. This works across multiple devices or browser tabs.

What happens if the WebSocket connection drops?

The client SDK automatically attempts to reconnect using the configured reconnection policy (e.g., exponential backoff). During reconnection, the client may lose messages sent from the server. To handle this, implement a mechanism to retrieve missed messages (e.g., last message ID). The SignalR Service also has an idle timeout of 30 minutes; if no data is sent, the connection may be closed.

How do I scale Azure SignalR Service?

You can increase the unit count in the Azure portal or via CLI. Each unit adds capacity for 1,000 concurrent connections. You can also enable autoscaling based on metrics like connection count. For geographic scaling, deploy instances in multiple regions and use a load balancer like Azure Traffic Manager to route users to the nearest instance.

Can I use Azure SignalR Service with Azure Functions without an app server?

Yes, that's serverless mode. You use the `SignalRConnectionInfo` input binding to generate the negotiation endpoint in your function, and the `SignalR` output binding to send messages. The function app handles negotiation and message sending on demand. No persistent app server is needed.

How do I monitor Azure SignalR Service?

Use Azure Monitor metrics: connection count, message count, connection errors, etc. Enable diagnostic settings to send logs to Log Analytics, Storage, or Event Hubs. You can also set up alerts on critical metrics like high error rates or approaching connection limits.

Terms Worth Knowing

Ready to put this to the test?

You've just covered Azure SignalR Service for Real-Time Apps — now see how well it sticks with free AZ-204 practice questions. Full explanations included, no account needed.

Done with this chapter?