Aspire.Hosting.Azure.WebPubSub 17.0.0

Prefix Reserved
dotnet add package Aspire.Hosting.Azure.WebPubSub --version 17.0.0
                    
NuGet\Install-Package Aspire.Hosting.Azure.WebPubSub -Version 17.0.0
                    
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="Aspire.Hosting.Azure.WebPubSub" Version="17.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aspire.Hosting.Azure.WebPubSub" Version="17.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Aspire.Hosting.Azure.WebPubSub" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Aspire.Hosting.Azure.WebPubSub --version 17.0.0
                    
#r "nuget: Aspire.Hosting.Azure.WebPubSub, 17.0.0"
                    
#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.
#:package Aspire.Hosting.Azure.WebPubSub@17.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aspire.Hosting.Azure.WebPubSub&version=17.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Aspire.Hosting.Azure.WebPubSub&version=17.0.0
                    
Install as a Cake Tool

Azure Web PubSub hosting integration

Use this integration to model, configure, and orchestrate Azure Web PubSub in an Aspire solution.

Getting started

Prerequisites

  • Azure subscription for Azure deployment - create one for free
  • A container runtime such as Docker or Podman for local emulator use

Add the integration

From your AppHost directory, add the Aspire.Hosting.Azure.WebPubSub integration with the Aspire CLI:

aspire add Aspire.Hosting.Azure.WebPubSub
aspire add Aspire.Hosting.Dotnet

Usage example

In the AppHost, add a WebPubSub connection and reference it from another resource with either C# or TypeScript:

C#

var wps = builder.AddAzureWebPubSub("wps1");

var web = builder.AddDotnetProject("webfrontend", "../WebPubSubWeb/WebPubSubWeb.csproj")
                       .WithReference(wps);

TypeScript

const wps = await builder.addAzureWebPubSub("wps1");

const web = await builder.addNodeApp("webfrontend", "../web-frontend", "server.js")
                       .withReference(wps);

Run locally with the emulator

Call RunAsEmulator to use mcr.microsoft.com/webpubsub/emulator:1.0.0-beta.3 during local development. Aspire supplies the HTTP endpoint and access key in the connection string. Publishing continues to provision Azure Web PubSub.

C#

var wps = builder.AddAzureWebPubSub("wps1").RunAsEmulator();
var chat = wps.AddHub("chat");

var web = builder.AddDotnetProject("webfrontend", "../WebPubSubWeb/WebPubSubWeb.csproj")
                 .WithReference(chat)
                 .WaitFor(wps);

chat.AddEventHandler($"{web.GetEndpoint("http")}/events", systemEvents: ["connected"]);

TypeScript

const wps = await builder.addAzureWebPubSub("wps1").runAsEmulator();
const chat = await wps.addHub("chat");

const web = await builder.addNodeApp("webfrontend", "../web-frontend", "server.js")
                         .withReference(chat)
                         .waitFor(wps);

Event handlers configured with AddEventHandler also run in the emulator. Use an HTTP endpoint for local callbacks; event handler authentication is not supported by the emulator. JavaScript clients using @azure/web-pubsub need allowInsecureConnection: true when connecting to its HTTP endpoint.

To select a fixed host port, configure the emulator endpoint:

var wps = builder.AddAzureWebPubSub("wps1")
                 .RunAsEmulator(emulator => emulator.WithEndpoint("emulator", endpoint => endpoint.Port = 8080));

Connection Properties

When you reference an Azure Web PubSub resource using WithReference, the following connection properties are made available to the consuming project:

Azure Web PubSub service

The Azure Web PubSub resource exposes the following connection properties:

Property Name Description
Uri The service endpoint, typically https://<resource-name>.webpubsub.azure.com/, or the local HTTP endpoint when using the emulator

Azure Web PubSub hub

The Azure Web PubSub hub resource inherits all properties from its parent Azure Web PubSub service and adds:

Property Name Description
HubName The name of the Web PubSub hub

Aspire exposes each property as an environment variable named [RESOURCE]_[PROPERTY]. For instance, the Uri property of a resource called wps1 becomes WPS1_URI, and the HubName property of a hub called chat becomes CHAT_HUBNAME.

Additional documentation

Feedback & contributing

https://github.com/microsoft/aspire

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Aspire.Hosting.Azure.WebPubSub:

Package Downloads
Aspire.Hosting.Azure.Provisioning.WebPubSub

Opt-in Azure Provisioning Web PubSub APIs for polyglot Aspire AppHosts.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
17.0.0 234 11/18/2026
13.6.5 226 11/10/2026
13.6.4 205 10/24/2026
13.6.3 133 10/21/2026
13.6.2 165 10/20/2026
13.6.1 225 10/7/2026
13.6.0 251 9/29/2026
13.5.4 366 9/15/2026
13.5.3 250 8/25/2026
13.5.2 173 8/21/2026
13.5.1 184 8/20/2026
13.5.0 184 8/18/2026
13.4.6 670 6/19/2026
13.4.5 199 6/17/2026
13.4.4 172 6/15/2026
13.4.3 221 6/8/2026
13.4.2 189 6/3/2026
13.4.1 160 6/3/2026
13.4.0 277 6/1/2026
13.3.5 563 5/21/2026
Loading failed