BeforeStartEvent
Classnet10.0
This event is published before the application starts.
namespace Aspire.Hosting.ApplicationModel;
public class BeforeStartEvent : Aspire.Hosting.Eventing.IDistributedApplicationEvent{ // ...}Remarks
Section titled Remarks Subscribing to this event is analogous to implementing the
IDistributedApplicationLifecycleHook.BeforeStartAsync method. This event provides access to the IServiceProvider interface to resolve dependencies including DistributedApplicationModel service which is passed in as an argument in IDistributedApplicationLifecycleHook.BeforeStartAsync. Constructors1
Section titled Constructors This event is published before the application starts.
Properties2
Section titled PropertiesView all properties
Examples
Section titled ExamplesSubscribe to the event and resolve the distributed application model.
var builder = DistributedApplication.CreateBuilder(args);builder.Eventing.Subscribe<BeforeStartEvent>(async (@event, cancellationToken) => { var appModel = @event.Services.GetRequiredService<DistributedApplicationModel>(); // Mutate the distributed application model.});