次の方法で共有


AfterEndpointsAllocatedEvent Constructor

Definition

This event is published after all endpoints have been allocated.

public AfterEndpointsAllocatedEvent (IServiceProvider services, Aspire.Hosting.ApplicationModel.DistributedApplicationModel model);
new Aspire.Hosting.ApplicationModel.AfterEndpointsAllocatedEvent : IServiceProvider * Aspire.Hosting.ApplicationModel.DistributedApplicationModel -> Aspire.Hosting.ApplicationModel.AfterEndpointsAllocatedEvent
Public Sub New (services As IServiceProvider, model As DistributedApplicationModel)

Parameters

services
IServiceProvider

The IServiceProvider instance.

Examples

Subscribe to the AfterEndpointsAllocatedEvent event and resolve the distributed application model.

var builder = DistributedApplication.CreateBuilder(args);
builder.Eventing.Subscribe<AfterEndpointsAllocatedEvent>(async (@event, cancellationToken) => {
  var appModel = @event.ServiceProvider.GetRequiredService<DistributedApplicationModel>();
  // Update configuration of resource based on final endpoint configuration
});

Remarks

Subscribing to this event is analogous to implementing the AfterEndpointsAllocatedAsync(DistributedApplicationModel, CancellationToken) method. This event provides access to the IServiceProvider interface to resolve dependencies including DistributedApplicationModel service which is passed in as an argument in AfterEndpointsAllocatedAsync(DistributedApplicationModel, CancellationToken).

Applies to