Skip to content
DocsTry Aspire
DocsTry

AzureSignalRExtensions Methods

ClassMethods4 members
Provides extension methods for adding the Azure SignalR resources to the application model.
AddAzureSignalR(IDistributedApplicationBuilder, string)Section titled AddAzureSignalR(IDistributedApplicationBuilder, string)extensionIResourceBuilder<AzureSignalRResource>
Adds an Azure SignalR resource to the application model.
public static class AzureSignalRExtensions
{
public static IResourceBuilder<AzureSignalRResource> AddAzureSignalR(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder.
namestringThe 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)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder.
namestringThe name of the resource. This name will be used as the connection string name when referenced in a dependency.
serviceModeAzureSignalRServiceModeThe 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>>)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<AzureSignalRResource>The Azure SignalR resource builder.
configureContainerAction<IResourceBuilder<AzureSignalREmulatorResource>>optionalCallback 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[])extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<T>The resource to which the specified roles will be assigned.
targetIResourceBuilder<AzureSignalRResource>The target Azure SignalR resource.
rolesSignalRBuiltInRole[]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);