Share via


IDistributedApplicationBuilder Interface

Definition

A builder for creating instances of DistributedApplication.

public interface IDistributedApplicationBuilder
type IDistributedApplicationBuilder = interface
Public Interface IDistributedApplicationBuilder
Derived

Examples

This example shows a distributed application that contains a .NET project (InventoryService) that uses a Redis cache and a PostgreSQL database. The builder is created using the CreateBuilder(String[]) method.

The AddRedis and AddPostgres methods are used to add Redis and PostgreSQL container resources. The results of the methods are stored in variables for later use.

var builder = DistributedApplication.CreateBuilder(args);
var cache = builder.AddRedis("cache");
var inventoryDatabase = builder.AddPostgres("postgres").AddDatabase("inventory");
builder.AddProject<Projects.InventoryService>("inventoryservice")
       .WithReference(cache)
       .WithReference(inventory);
builder.Build().Run();

Remarks

The IDistributedApplicationBuilder is the central interface for defining the resources which are orchestrated by the DistributedApplication when the app host is launched.

To create an instance of the IDistributedApplicationBuilder interface developers should use the CreateBuilder(String[]) method. Once the builder is created extension methods which target the IDistributedApplicationBuilder interface can be used to add resources to the distributed application.

Properties

AppHostAssembly

Assembly of the app host project.

AppHostDirectory

Directory of the project where the app host is located. Defaults to the content root if there's no project.

Configuration

Gets the set of key/value configuration properties.

Environment

Gets information about the hosting environment an application is running in.

Eventing

Eventing infrastructure for AppHost lifecycle.

ExecutionContext

Execution context for this invocation of the AppHost.

Resources

Gets the collection of resources for the distributed application.

Services

Gets a collection of services for the application to compose. This property is useful for adding user-provided or framework-provided services.

Methods

AddResource<T>(T)

Adds a resource of type T to the distributed application.

Build()

Builds and returns a new DistributedApplication instance. This can only be called once.

CreateResourceBuilder<T>(T)

Creates a new resource builder based on an existing resource.

Extension Methods

AddAzureAppConfiguration(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureAppConfigurationResource>,ResourceModuleConstruct, AppConfigurationStore>)

Adds an Azure App Configuration resource to the application model.

AddAzureAppConfiguration(IDistributedApplicationBuilder, String)

Adds an Azure App Configuration resource to the application model.

AddAzureApplicationInsights(IDistributedApplicationBuilder, String, IResourceBuilder<AzureLogAnalyticsWorkspaceResource>, Action<IResourceBuilder<AzureApplicationInsightsResource>, ResourceModuleConstruct,ApplicationInsightsComponent>)

Adds an Azure Application Insights resource to the application model.

AddAzureApplicationInsights(IDistributedApplicationBuilder, String, IResourceBuilder<AzureLogAnalyticsWorkspaceResource>)

Adds an Azure Application Insights resource to the application model.

AddAzureApplicationInsights(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureApplicationInsightsResource>,ResourceModuleConstruct, ApplicationInsightsComponent>)

Adds an Azure Application Insights resource to the application model.

AddAzureApplicationInsights(IDistributedApplicationBuilder, String)

Adds an Azure Application Insights resource to the application model.

AddBicepTemplate(IDistributedApplicationBuilder, String, String)

Adds an Azure Bicep resource to the application model.

AddBicepTemplateString(IDistributedApplicationBuilder, String, String)

Adds an Azure Bicep resource to the application model.

AddAzureConstruct(IDistributedApplicationBuilder, String, Action<ResourceModuleConstruct>)

Adds an Azure construct resource to the application model.

AddAzureContainerAppsInfrastructure(IDistributedApplicationBuilder)

Adds the necessary infrastructure for Azure Container Apps to the distributed application builder.

AddAzureCosmosDB(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureCosmosDBResource>, ResourceModuleConstruct,CosmosDBAccount,IEnumerable<CosmosDBSqlDatabase>>)

Adds an Azure Cosmos DB connection to the application model.

AddAzureCosmosDB(IDistributedApplicationBuilder, String)

Adds an Azure Cosmos DB connection to the application model.

AddAzureEventHubs(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureEventHubsResource>, ResourceModuleConstruct,EventHubsNamespace>)

Adds an Azure Event Hubs Namespace resource to the application model. This resource can be used to create Event Hub resources.

AddAzureEventHubs(IDistributedApplicationBuilder, String)

Adds an Azure Event Hubs Namespace resource to the application model. This resource can be used to create Event Hub resources.

AddAzureFunctionsProject<TProject>(IDistributedApplicationBuilder, String)

Adds an Azure Functions project to the distributed application.

AddAzureKeyVault(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureKeyVaultResource>,ResourceModuleConstruct,KeyVault>)

Adds an Azure Key Vault resource to the application model.

AddAzureKeyVault(IDistributedApplicationBuilder, String)

Adds an Azure Key Vault resource to the application model.

AddAzureLogAnalyticsWorkspace(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureLogAnalyticsWorkspaceResource>, ResourceModuleConstruct,OperationalInsightsWorkspace>)

Adds an Azure Log Analytics Workspace resource to the application model.

AddAzureLogAnalyticsWorkspace(IDistributedApplicationBuilder, String)

Adds an Azure Application Insights resource to the application model.

AddAzureOpenAI(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureOpenAIResource>, ResourceModuleConstruct,CognitiveServicesAccount,IEnumerable<CognitiveServicesAccountDeployment>>)

Adds an Azure OpenAI resource to the application model.

AddAzureOpenAI(IDistributedApplicationBuilder, String)

Adds an Azure OpenAI resource to the application model.

AddAzurePostgresFlexibleServer(IDistributedApplicationBuilder, String)

Adds an Azure PostgreSQL Flexible Server resource to the application model.

AddAzureProvisioning(IDistributedApplicationBuilder)

Adds support for generating azure resources dynamically during application startup. The application must configure the appropriate subscription, location.

AddAzureInfrastructure(IDistributedApplicationBuilder, String, Action<AzureResourceInfrastructure>)

Adds an Azure provisioning resource to the application model.

AddAzureRedis(IDistributedApplicationBuilder, String)

Adds an Azure Cache for Redis resource to the application model.

AddAzureSearch(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureSearchResource>,ResourceModuleConstruct,SearchService>)

Adds an Azure AI Search service resource to the application model.

AddAzureSearch(IDistributedApplicationBuilder, String)

Adds an Azure AI Search service resource to the application model.

AddAzureServiceBus(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureServiceBusResource>, ResourceModuleConstruct,ServiceBusNamespace>)

Adds an Azure Service Bus Namespace resource to the application model. This resource can be used to create queue, topic, and subscription resources.

AddAzureServiceBus(IDistributedApplicationBuilder, String)

Adds an Azure Service Bus Namespace resource to the application model. This resource can be used to create queue, topic, and subscription resources.

AddAzureSignalR(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureSignalRResource>,ResourceModuleConstruct,SignalRService>)

Adds an Azure SignalR resource to the application model.

AddAzureSignalR(IDistributedApplicationBuilder, String)

Adds an Azure SignalR resource to the application model.

AddAzureSqlServer(IDistributedApplicationBuilder, String)

Adds an Azure SQL Database (server) resource to the application model.

AddAzureStorage(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureStorageResource>,ResourceModuleConstruct,StorageAccount>)

Adds an Azure Storage resource to the application model.This resource can be used to create Azure blob, table, and queue resources.

AddAzureStorage(IDistributedApplicationBuilder, String)

Adds an Azure Storage resource to the application model. This resource can be used to create Azure blob, table, and queue resources.

AddAzureWebPubSub(IDistributedApplicationBuilder, String, Action<IResourceBuilder<AzureWebPubSubResource>,ResourceModuleConstruct,WebPubSubService>)

Adds an Azure Web PubSub resource to the application model.

AddAzureWebPubSub(IDistributedApplicationBuilder, String)

Adds an Azure Web PubSub resource to the application model. Change sku: WithParameter("sku", "Standard_S1") Change capacity: WithParameter("capacity", 2)

AddAWSCDKStack(IDistributedApplicationBuilder, String, String)

Adds an AWS CDK stack as resource.

AddAWSCDKStack(IDistributedApplicationBuilder, String)

Adds an AWS CDK stack as resource. The CloudFormation stack name will be the resource name prefixed with 'Aspire-'

AddAWSCDKStack<T>(IDistributedApplicationBuilder, String, ConstructBuilderDelegate<T>)

Adds and build an AWS CDK stack as resource.

AddAWSCloudFormationStack(IDistributedApplicationBuilder, String, String)

Add a CloudFormation stack for provisioning application resources.

AddAWSCloudFormationStack(IDistributedApplicationBuilder, String)

Add a CloudFormation stack for provisioning application resources.

AddAWSCloudFormationTemplate(IDistributedApplicationBuilder, String, String, String)

Add a CloudFormation stack for provisioning application resources.

AddAWSCloudFormationTemplate(IDistributedApplicationBuilder, String, String)

Add a CloudFormation stack for provisioning application resources.

AddContainer(IDistributedApplicationBuilder, String, String, String)

Adds a container resource to the application.

AddContainer(IDistributedApplicationBuilder, String, String)

Adds a container resource to the application. Uses the "latest" tag.

AddDockerfile(IDistributedApplicationBuilder, String, String, String, String)

Adds a Dockerfile to the application model that can be treated like a container resource.

AddElasticsearch(IDistributedApplicationBuilder, String, IResourceBuilder<ParameterResource>, Nullable<Int32>)

Adds an Elasticsearch container resource to the application model.

AddExecutable(IDistributedApplicationBuilder, String, String, String, Object[])

Adds an executable resource to the application model.

AddExecutable(IDistributedApplicationBuilder, String, String, String, String[])

Adds an executable resource to the application model.

AddGarnet(IDistributedApplicationBuilder, String, Nullable<Int32>)

Adds a Garnet container to the application model.

AddDapr(IDistributedApplicationBuilder, Action<DaprOptions>)

Adds Dapr support to Aspire, including the ability to add Dapr sidecar to application resource.

AddDaprComponent(IDistributedApplicationBuilder, String, String, DaprComponentOptions)

Adds a Dapr component to the application model.

AddDaprPubSub(IDistributedApplicationBuilder, String, DaprComponentOptions)

Adds a "generic" Dapr pub-sub component to the application model. Aspire will configure an appropriate type when running or deploying.

AddDaprStateStore(IDistributedApplicationBuilder, String, DaprComponentOptions)

Adds a Dapr state store component to the application model. Aspire will configure an appropriate type when running or deploying.

AddKafka(IDistributedApplicationBuilder, String, Nullable<Int32>)

Adds a Kafka resource to the application. A container is used for local development.

AddKeycloak(IDistributedApplicationBuilder, String, Nullable<Int32>, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)

Adds a Keycloak container to the application model.

AddMilvus(IDistributedApplicationBuilder, String, IResourceBuilder<ParameterResource>, Nullable<Int32>)

Adds a Milvus container resource to the application model.

AddMongoDB(IDistributedApplicationBuilder, String, Nullable<Int32>, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)

Adds a MongoDB resource to the application model. A container is used for local development.

AddMongoDB(IDistributedApplicationBuilder, String, Nullable<Int32>)

Adds a MongoDB resource to the application model. A container is used for local development.

AddMySql(IDistributedApplicationBuilder, String, IResourceBuilder<ParameterResource>, Nullable<Int32>)

Adds a MySQL server resource to the application model. For local development a container is used.

AddNats(IDistributedApplicationBuilder, String, Nullable<Int32>)

Adds a NATS server resource to the application model. A container is used for local development.

AddNodeApp(IDistributedApplicationBuilder, String, String, String, String[])

Adds a node application to the application model. Node should available on the PATH.

AddNpmApp(IDistributedApplicationBuilder, String, String, String, String[])

Adds a node application to the application model. Executes the npm command with the specified script name.

AddOracle(IDistributedApplicationBuilder, String, IResourceBuilder<ParameterResource>, Nullable<Int32>)

Adds a Oracle Server resource to the application model. A container is used for local development.

AddOrleans(IDistributedApplicationBuilder, String)

Adds an Orleans service to the application.

AddConnectionString(IDistributedApplicationBuilder, String, String)

Adds a parameter to the distributed application but wrapped in a resource with a connection string for use with WithReference<TDestination>(IResourceBuilder<TDestination>, IResourceBuilder<IResourceWithConnectionString>, String, Boolean)

AddParameter(IDistributedApplicationBuilder, String, ParameterDefault, Boolean, Boolean)

Adds a parameter resource to the application, with a value coming from a ParameterDefault.

AddParameter(IDistributedApplicationBuilder, String, Boolean)

Adds a parameter resource to the application.

AddParameter(IDistributedApplicationBuilder, String, Func<String>, Boolean, Boolean)

Adds a parameter resource to the application with a value coming from a callback function.

AddParameter(IDistributedApplicationBuilder, String, String, Boolean, Boolean)

Adds a parameter resource to the application with a given value.

AddParameterFromConfiguration(IDistributedApplicationBuilder, String, String, Boolean)

Adds a parameter resource to the application, with a value coming from configuration.

AddPostgres(IDistributedApplicationBuilder, String, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>, Nullable<Int32>)

Adds a PostgreSQL resource to the application model. A container is used for local development.

AddProject(IDistributedApplicationBuilder, String, String, Action<ProjectResourceOptions>)

Adds a .NET project to the application model.

AddProject(IDistributedApplicationBuilder, String, String, String)

Adds a .NET project to the application model.

AddProject(IDistributedApplicationBuilder, String, String)

Adds a .NET project to the application model.

AddProject<TProject>(IDistributedApplicationBuilder, String, Action<ProjectResourceOptions>)

Adds a .NET project to the application model.

AddProject<TProject>(IDistributedApplicationBuilder, String, String)

Adds a .NET project to the application model. By default, this will exist in a Projects namespace. e.g. Projects.MyProject. If the project is not in a Projects namespace, make sure a project reference is added from the AppHost project to the target project.

AddProject<TProject>(IDistributedApplicationBuilder, String)

Adds a .NET project to the application model.

AddPythonApp(IDistributedApplicationBuilder, String, String, String, String, String[])

Adds a python application with a virtual environment to the application model.

AddPythonApp(IDistributedApplicationBuilder, String, String, String, String[])

Adds a python application with a virtual environment to the application model.

AddPythonProject(IDistributedApplicationBuilder, String, String, String, String, String[])
Obsolete.

This method is retained only for compatibility.

AddPythonProject(IDistributedApplicationBuilder, String, String, String, String[])
Obsolete.

This method is retained only for compatibility.

AddQdrant(IDistributedApplicationBuilder, String, IResourceBuilder<ParameterResource>, Nullable<Int32>, Nullable<Int32>)

Adds a Qdrant resource to the application. A container is used for local development.

AddRabbitMQ(IDistributedApplicationBuilder, String, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>, Nullable<Int32>)

Adds a RabbitMQ container to the application model.

AddRedis(IDistributedApplicationBuilder, String, Nullable<Int32>)

Adds a Redis container to the application model.

AddAWSSDKConfig(IDistributedApplicationBuilder)

Add a configuration for resolving region and credentials for the AWS SDK for .NET.

AddSeq(IDistributedApplicationBuilder, String, Nullable<Int32>)

Adds a Seq server resource to the application model. A container is used for local development.

AddSqlServer(IDistributedApplicationBuilder, String, IResourceBuilder<ParameterResource>, Nullable<Int32>)

Adds a SQL Server resource to the application model. A container is used for local development.

AddValkey(IDistributedApplicationBuilder, String, Nullable<Int32>)

Adds a Valkey container to the application model.

Applies to