Azure WebPubSub resource types for Aspire.
$ dotnet add package Aspire.Hosting.Azure.WebPubSubProvides extension methods and resource definitions for an Aspire AppHost to configure Azure Web PubSub.
Install the Aspire Azure Web PubSub Hosting library with NuGet:
dotnet add package Aspire.Hosting.Azure.WebPubSub
In the AppHost.cs file of AppHost, add a WebPubSub connection and consume the connection using the following methods:
var wps = builder.AddAzureWebPubSub("wps1");
var web = builder.AddProject<Projects.WebPubSubWeb>("webfrontend")
.WithReference(wps);
When you reference an Azure Web PubSub resource using WithReference, the following connection properties are made available to the consuming project:
| Property Name | Description |
|---|---|
Uri | The HTTPS endpoint for the Web PubSub service, typically https://<resource-name>.webpubsub.azure.com/ |
Aspire exposes each property as an environment variable named [RESOURCE]_[PROPERTY]. For instance, the Uri property of a resource called wps1 becomes WPS1_URI.