AzureSignalRExtensions.WithRoleAssignments<T> Method

Definition

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 Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithRoleAssignments<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.AzureSignalRResource> target, params Azure.Provisioning.SignalR.SignalRBuiltInRole[] roles) where T : Aspire.Hosting.ApplicationModel.IResource;
static member WithRoleAssignments : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)> * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.AzureSignalRResource> * Azure.Provisioning.SignalR.SignalRBuiltInRole[] -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)> (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)
<Extension()>
Public Function WithRoleAssignments(Of T As IResource) (builder As IResourceBuilder(Of T), target As IResourceBuilder(Of AzureSignalRResource), ParamArray roles As SignalRBuiltInRole()) As IResourceBuilder(Of T)

Type Parameters

T

Parameters

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.

Returns

The updated IResourceBuilder<T> with the applied role assignments.

Examples

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);

Remarks

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);

Applies to