Skip to content
Docs Try Aspire

AzureSignalRExtensions Methods

Class Methods 4 members
Provides extension methods for adding the Azure SignalR resources to the application model.
AddAzureSignalR(IDistributedApplicationBuilder, string) Section titled AddAzureSignalR(IDistributedApplicationBuilder, string) extension IResourceBuilder<AzureSignalRResource>
Adds an Azure SignalR resource to the application model.
public static class AzureSignalRExtensions
{
public static IResourceBuilder<AzureSignalRResource> AddAzureSignalR(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder.
name string The name of the resource. This name will be used as the connection string name when referenced in a dependency.
IResourceBuilder<AzureSignalRResource> A reference to the ApplicationModel.IResourceBuilder`1.
By default references to the Azure SignalR resource will be assigned the following roles: - SignalRBuiltInRole.SignalRAppServer These can be replaced by calling AzureSignalRExtensions.WithRoleAssignments.
AddAzureSignalR(IDistributedApplicationBuilder, string, AzureSignalRServiceMode) Section titled AddAzureSignalR(IDistributedApplicationBuilder, string, AzureSignalRServiceMode) extension IResourceBuilder<AzureSignalRResource>
Adds an Azure SignalR resource to the application model.
public static class AzureSignalRExtensions
{
public static IResourceBuilder<AzureSignalRResource> AddAzureSignalR(
this IDistributedApplicationBuilder builder,
string name,
AzureSignalRServiceMode serviceMode)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder.
name string The name of the resource. This name will be used as the connection string name when referenced in a dependency.
serviceMode AzureSignalRServiceMode The service mode of the resource.
IResourceBuilder<AzureSignalRResource> A reference to the ApplicationModel.IResourceBuilder`1.
By default references to the Azure SignalR resource will be assigned the following roles: - SignalRBuiltInRole.SignalRAppServer Using AzureSignalRServiceMode.Serverless additionally adds: - SignalRBuiltInRole.SignalRRestApiOwner These can be replaced by calling AzureSignalRExtensions.WithRoleAssignments.
RunAsEmulator(IResourceBuilder<AzureSignalRResource>, Action<IResourceBuilder<AzureSignalREmulatorResource>>) Section titled RunAsEmulator(IResourceBuilder<AzureSignalRResource>, Action<IResourceBuilder<AzureSignalREmulatorResource>>) extension IResourceBuilder<AzureSignalRResource>
Configures an Azure SignalR resource to be emulated. This resource requires an AzureSignalRResource to be added to the application model. Please note that the resource will be emulated in Serverless mode.
public static class AzureSignalRExtensions
{
public static IResourceBuilder<AzureSignalRResource> RunAsEmulator(
this IResourceBuilder<AzureSignalRResource> builder,
Action<IResourceBuilder<AzureSignalREmulatorResource>>? configureContainer = null)
{
// ...
}
}
builder IResourceBuilder<AzureSignalRResource> The Azure SignalR resource builder.
configureContainer Action<IResourceBuilder<AzureSignalREmulatorResource>> optional Callback that exposes underlying container used for emulation to allow for customization.
IResourceBuilder<AzureSignalRResource> A reference to the ApplicationModel.IResourceBuilder`1.
This version of the package defaults to the tag of the / container image.
WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureSignalRResource>, SignalRBuiltInRole[]) Section titled WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureSignalRResource>, SignalRBuiltInRole[]) extension IResourceBuilder<T>
Assigns the specified roles to the given resource, granting it the necessary permissions on the target Azure SignalR resource. This replaces the default role assignments for the resource.
public static class AzureSignalRExtensions
{
public static IResourceBuilder<T> WithRoleAssignments<T>(
this IResourceBuilder<T> builder,
IResourceBuilder<AzureSignalRResource> target,
params SignalRBuiltInRole[] roles)
{
// ...
}
}
builder IResourceBuilder<T> The resource to which the specified roles will be assigned.
target IResourceBuilder<AzureSignalRResource> The target Azure SignalR resource.
roles SignalRBuiltInRole[] The built-in SignalR roles to be assigned.
IResourceBuilder<T> The updated ApplicationModel.IResourceBuilder`1 with the applied role assignments.
Assigns the SignalRContributor role to the 'Projects.Api' project.
var builder = DistributedApplication.CreateBuilder(args);
var signalr = builder.AddAzureSignalR("signalr");
var api = builder.AddProject<Projects.Api>("api")
.WithRoleAssignments(signalr, SignalRBuiltInRole.SignalRContributor)
.WithReference(signalr);