DistributedApplication
Hosting.IHost and IAsyncDisposable interfaces. namespace Aspire.Hosting;
public class DistributedApplication : Microsoft.Extensions.Hosting.IHost, System.IAsyncDisposable, System.IDisposable{ // ...}Remarks
Section titled Remarks The Distributed is an implementation of the Hosting. interface that orchestrates an Aspire application. To build an instance of the Distributed class, use the Distributed method to create an instance of the I interface. Using the I interface you can configure the resources that comprise the distributed application and describe the dependencies between them.
Once the distributed application has been defined use the I method to create an instance of the Distributed class. The Distributed class exposes a Distributed method which then starts the distributed application and its resources.
The Distributed method provides additional options for constructing the I including disabling the Aspire dashboard (see Distributed) or allowing unsecured communication between the browser and dashboard, and dashboard and AppHost (see Distributed.
var builder = DistributedApplication.CreateBuilder(args);var inventoryDatabase = builder.AddPostgres( "mypostgres").AddDatabase("inventory");builder.AddProject<Projects.InventoryService>() .WithReference(inventoryDatabase);
builder.Build().Run();Constructors1
Section titled ConstructorsDistributedApplication class. Properties3
Section titled PropertiesMethods9
Section titled MethodsCreateBuilder staticIDistributedApplicationBuilder interface. IDistributedApplicationBuilder with the specified command-line arguments. IDistributedApplicationBuilder interface with the specified options. DisposevirtualHosting.IHost . DisposeAsync virtualValueTask Hosting.IHost . Hosting.IHostedService instances are stopped. TaskHosting.IHostedService instances are stopped. TaskHosting.IHostedService objects configured for the program. The application will run until interrupted or until IHostApplicationLifetime.StopApplication is called.