Azure.Messaging.WebPubSub 1.0.0-beta.2

The ID prefix of this package has been reserved for one of the owners of this package by Prefix Reserved
This is a prerelease version of Azure.Messaging.WebPubSub.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Azure.Messaging.WebPubSub --version 1.0.0-beta.2
NuGet\Install-Package Azure.Messaging.WebPubSub -Version 1.0.0-beta.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Azure.Messaging.WebPubSub" Version="1.0.0-beta.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Azure.Messaging.WebPubSub --version 1.0.0-beta.2
#r "nuget: Azure.Messaging.WebPubSub, 1.0.0-beta.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Azure.Messaging.WebPubSub as a Cake Addin
#addin nuget:?package=Azure.Messaging.WebPubSub&version=1.0.0-beta.2&prerelease

// Install Azure.Messaging.WebPubSub as a Cake Tool
#tool nuget:?package=Azure.Messaging.WebPubSub&version=1.0.0-beta.2&prerelease

Azure Web PubSub service client library for .NET

Azure Web PubSub Service is a service that enables you to build real-time messaging web applications using WebSockets and the publish-subscribe pattern. Any platform supporting WebSocket APIs can connect to the service easily, e.g. web pages, mobile applications, edge devices, etc. The service manages the WebSocket connections for you and allows up to 100K concurrent connections. It provides powerful APIs for you to manage these clients and deliver real-time messages.

Any scenario that requires real-time publish-subscribe messaging between server and clients or among clients, can use Azure Web PubSub service. Traditional real-time features that often require polling from server or submitting HTTP requests, can also use Azure Web PubSub service.

This library can be used to do the following actions. Details about the terms used here are described in Key concepts section.

  • Send messages to hubs and groups.
  • Send messages to particular users and connections.
  • Organize users and connections into groups.
  • Close connections
  • Grant, revoke, and check permissions for an existing connection

Source code | Package | API reference documentation | Product documentation | Samples

Getting started

Install the package

Install the client library from NuGet:

dotnet add package Azure.Messaging.WebPubSub --prerelease


Authenticate the client

In order to interact with the service, you'll need to create an instance of the WebPubSubServiceClient class. To make this possible, you'll need the connection string or a key, which you can access in the Azure portal.

Create a WebPubSubServiceClient

var serviceClient = new WebPubSubServiceClient(new Uri(endpoint), "some_hub", new AzureKeyCredential(key));

Key concepts


Connections, represented by a connection id, represent an individual websocket connection to the Web PubSub service. Connection id is always unique.


Hub is a logical concept for a set of connections. Connections are always connected to a specific hub. Messages that are broadcast to the hub are dispatched to all connections to that hub. Hub can be used for different applications, different applications can share one Azure Web PubSub service by using different hub names.


Group allow broadcast messages to a subset of connections to the hub. You can add and remove users and connections as needed. A client can join multiple groups, and a group can contain multiple clients.


Connections to Web PubSub can belong to one user. A user might have multiple connections, for example when a single user is connected across multiple devices or multiple browser tabs.


Using this library, you can send messages to the client connections. A message can either be string text, JSON or binary payload.


Broadcast a text message to all clients

var serviceClient = new WebPubSubServiceClient(new Uri(endpoint), "some_hub", new AzureKeyCredential(key));

serviceClient.SendToAll("Hello World!");

Broadcast a JSON message to all clients

var serviceClient = new WebPubSubServiceClient(new Uri(endpoint), "some_hub", new AzureKeyCredential(key));

            Foo = "Hello World!",
            Bar = 42

Broadcast a binary message to all clients

var serviceClient = new WebPubSubServiceClient(new Uri(endpoint), "some_hub", new AzureKeyCredential(key));

Stream stream = BinaryData.FromString("Hello World!").ToStream();
serviceClient.SendToAll(RequestContent.Create(stream), ContentType.ApplicationOctetStream);


Setting up console logging

You can also easily enable console logging if you want to dig deeper into the requests you're making against the service.

Next steps

Please take a look at the samples directory for detailed examples on how to use this library.


This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Azure.Messaging.WebPubSub:

Package Downloads
Microsoft.Azure.WebPubSub.AspNetCore The ID prefix of this package has been reserved for one of the owners of this package by

Azure SDK client library for the WebPubSub service

Microsoft.Azure.WebJobs.Extensions.WebPubSub The ID prefix of this package has been reserved for one of the owners of this package by

Azure Functions extension for the WebPubSub service

Blazor.Ninja.Client.Local The ID prefix of this package has been reserved for one of the owners of this package by

Blazor.Ninja Local Client Package


Toggly.FeatureManagement extends Microsoft.FeatureManagement with extensions to handle feature state changes, Decorate and register services that are injected when a feature is on, feature usage tracking, and integration with


Software development kit to call RPC functions.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Azure.Messaging.WebPubSub:

Repository Stars
This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at or our versioned developer docs at
Version Downloads Last updated
1.3.0 497,029 11/21/2022
1.2.0 162,799 11/7/2022
1.1.0 4,274 10/29/2022
1.1.0-beta.1 1,071 8/11/2022
1.0.0 344,436 11/12/2021
1.0.0-beta.3 38,108 9/8/2021
1.0.0-beta.2 11,494 7/15/2021
1.0.0-beta.1 32,368 4/26/2021