AfterEndpointsAllocatedEvent Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This event is published after all endpoints have been allocated.
public class AfterEndpointsAllocatedEvent : Aspire.Hosting.Eventing.IDistributedApplicationEvent
type AfterEndpointsAllocatedEvent = class
interface IDistributedApplicationEvent
Public Class AfterEndpointsAllocatedEvent
Implements IDistributedApplicationEvent
- Inheritance
-
AfterEndpointsAllocatedEvent
- Implements
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
});
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).
After |
This event is published after all endpoints have been allocated. |
Model |
The DistributedApplicationModel instance. |
Services |
The IServiceProvider instance. |