Skip to main content

Overview

This sample demonstrates how to push real-time notifications to C# clients using Azure SignalR Service combined with Azure Functions and PlayFab’s Rules and Matchmaking systems. When a player logs in, a PlayFab Rule fires an Azure Function that broadcasts the login event to connected clients via SignalR. When two players enter a matchmaking queue and a match is found, a second Rule triggers a queue-based Azure Function that notifies both players through SignalR. Once matched, the players can exchange chat messages in real time.

What the sample demonstrates

  • Push notifications from PlayFab events to clients without polling
  • PlayFab Rules triggering Azure Functions on player_logged_in and match_found events
  • Azure Queue Functions as an event bridge between PlayFab and SignalR
  • A console C# client that connects to SignalR and participates in matchmaking and chat

Prerequisites

Architecture

PlayFab client (C#)
    │  ExecuteFunction / matchmaking API calls

PlayFab (Rules engine + Matchmaking)
    │  HTTP trigger          Queue trigger (matchfound)
    ▼                            ▼
Azure Functions ─────────────────────────
    │  SignalR output binding

Azure SignalR Service
    │  WebSocket push

C# client (MessagingClient)
ComponentRole
PlayFabAuthentication, Rules engine, Matchmaking queue
Azure FunctionsHTTP + Queue triggered functions; bridge between PlayFab and SignalR
Azure SignalR ServiceManages WebSocket connections; delivers push messages to clients
Azure Storage QueueCarries match_found payloads from PlayFab to the MatchFound function
MessagingClientConsole app that logs in, connects to SignalR, and joins matchmaking

Azure setup

1

Create a SignalR Service instance

Follow the Azure SignalR Service quickstart to provision a new SignalR Service instance in the Azure Portal.
2

Create a Function App

Create a new Function App as described in the Azure Functions quickstart.
The Function App provisioning wizard requires you to create or select a Storage Account. Take note of this storage account — you will need its connection string in a later step.
3

Create the matchfound queue

  1. Open the Azure Portal and navigate to the Storage Account associated with your Function App.
  2. Under Queue service, click Queues.
  3. Click + to add a new queue.
  4. Name the queue exactly matchfound and click OK.
The queue name must be matchfound (all lowercase, no spaces). This name is registered in PlayFab as the queue trigger for the MatchFound function.

Configuration

1

Set the SignalR connection string

  1. In the Azure Portal, open your SignalR Service instance.
  2. Navigate to Settings → Keys.
  3. Copy the full CONNECTION STRING value.
  4. Open local.settings.json in the PlayFab.SignalRSample project.
  5. Replace the placeholder value for AzureSignalRConnectionString with the copied string.
2

Set the storage connection string

  1. In the Azure Portal, open the Storage Account associated with your Function App.
  2. Navigate to Settings → Access Keys.
  3. Copy the full Connection String value.
  4. Open local.settings.json in the PlayFab.SignalRSample project.
  5. Replace the placeholder value for AzureWebJobsStorage with the copied string.
3

Set the PlayFab Title ID

  1. Open the PlayFab Game Manager and select your title.
  2. Copy the 4–5 hex digit Title ID.
  3. Open Program.cs in the MessagingClient project.
  4. Find the constant declaration and replace XXXXX with your Title ID:
Program.cs
// Title Id from PlayFab. Set this depending on the title you're integrating with.
private const string TITLE_ID = "XXXXX";

Azure configuration

The connection strings you set locally must also be present in the Azure Portal so that the deployed Function App can use them.
1

Copy settings to Application Settings

  1. In the Azure Portal, open your Function App.
  2. Click Configuration under the Settings section.
  3. Under Application settings, click New application setting.
  4. Add AzureSignalRConnectionString with the same value you set locally.
  5. Repeat for AzureWebJobsStorage.
  6. Click Save.

Build and publish

1

Import the publish profile

  1. In the Azure Portal, open your Function App and click Get publish profile. Save the .PublishSettings file locally.
  2. In Visual Studio, right-click the PlayFab.SignalRSample project and choose Publish….
  3. Click Start, then Import Profile… in the bottom left.
  4. Select the .PublishSettings file you downloaded.
2

Build and publish the Function App

  1. Build the PlayFab.SignalRSample project. It will download the SignalR, WebJobs, and PlayFab NuGet packages automatically.
  2. Verify the project builds successfully.
  3. Publish the project using the imported publish profile.

PlayFab configuration

Get Azure Function URLs

Before configuring PlayFab, collect the invokable URLs for the HTTP-triggered functions:
  1. Open the Azure Portal and navigate to your Function App.
  2. For each HTTP function (GetSignalRConnection, PlayerLogin, SendChatMessage), click Get Function URL and copy it.
MatchFound does not have an HTTP URL — it is triggered by the Azure Storage Queue, not by HTTP.
Also copy the Storage Account Connection String from Settings → Access Keys in the portal. You will need it when registering the queue function.

Register functions and configure rules

1

Register HTTP Azure Functions

In PlayFab Game Manager, go to Automation → Cloud Script → Functions and register three HTTP functions:
Function nameTrigger typeURL
GetSignalRConnectionHTTPCopied URL
PlayerLoginHTTPCopied URL
SendChatMessageHTTPCopied URL
For each: click Register Function, select HTTP as the trigger type, enter the name, paste the URL, and save.
2

Register the MatchFound queue function

Register the queue-triggered function:
  1. Click Register Function.
  2. Select Queue as the trigger type.
  3. Enter MatchFound as the function name.
  4. Enter matchfound as the queue name.
  5. Paste the Storage Account connection string.
  6. Save the function.
3

Create Rules

Go to Automation → Rules and create two rules:Rule 1 — Broadcast Friend Login
FieldValue
NameBroadcast Friend Login
Event typecom.playfab.player_logged_in
Action typeExecute Azure Function
FunctionPlayerLogin
Rule 2 — Matchmaking Notifications
FieldValue
NameMatchmaking Notifications
Event typeplayfab.matchmaking.match_found
Action typeExecute Azure Function
FunctionMatchFound
4

Create the matchmaking queue

Go to Multiplayer → Matchmaking and click New Queue:
SettingValue
Queue namenr_simple
Min match size2
Max match size2
Save the queue.

Running the sample

Build the MessagingClient project and launch two or more instances of the executable (find the local .exe after building). Each instance will:
  1. Log in to PlayFab using a unique ID derived from the local machine name.
  2. Establish a SignalR WebSocket connection by calling GetSignalRConnection.
  3. Join the nr_simple matchmaking queue.
  4. Receive a real-time notification via SignalR when a match is found.
  5. Enter a chat channel with the matched player.
  6. Send and receive chat messages via SendChatMessage.
While waiting for a match, each client displays real-time login notifications whenever another instance logs in — this is driven by the Broadcast Friend Login rule. To exit the chat session, send an empty line (press Enter without typing a message).

Important notes

The Function App will spin down when idle. First-run requests after a period of inactivity may time out while the app cold-starts. Upgrade to the Azure Functions Premium plan to keep the app warm and avoid cold-start delays.
If more than two instances are running simultaneously, PlayFab may form multiple separate 2-player matches rather than one group match. Each pair of matched players gets its own isolated chat channel.

Tic Tac Toe Azure Functions

Another C# Azure Functions sample — game logic for the Tic Tac Toe Unity game.

Samples overview

Browse all PlayFab samples.

Build docs developers (and LLMs) love