Skip to content
Docs Try Aspire
Docs Try

IDistributedApplicationBuilder

Interface
📦 Aspire.Hosting v13.4.0
interface IDistributedApplicationBuilder {
readonly appHostDirectory: string;
readonly environment: IHostEnvironment;
readonly eventing: IDistributedApplicationEventing;
readonly executionContext: DistributedApplicationExecutionContext;
readonly pipeline: IDistributedApplicationPipeline;
readonly userSecretsManager: IUserSecretsManager;
addConnectionString(
name: string,
environmentVariableNameOrExpression?: ReferenceExpression): IResourceWithConnectionString;
addContainer(
name: string,
image: AddContainerOptions): ContainerResource;
addContainerRegistry(
name: string,
endpoint: ParameterResource,
repository?: ParameterResource): ContainerRegistryResource;
addCSharpApp(
name: string,
path: string,
options?: ProjectResourceOptions): CSharpAppResource;
addDockerfile(
name: string,
contextPath: string,
dockerfilePath?: string,
stage?: string): ContainerResource;
addDockerfileBuilder(name: string, contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise<void>, stage?: string): ContainerResource;
addDockerfileFactory(name: string, contextPath: string, dockerfileFactory: (arg: DockerfileFactoryContext) => Promise<string>, stage?: string): ContainerResource;
addDotnetTool(
name: string,
packageId: string): DotnetToolResource;
addEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise<void>): void;
addExecutable(
name: string,
command: string,
workingDirectory: string,
args: string[]): ExecutableResource;
addExternalService(
name: string,
url: ParameterResource): ExternalServiceResource;
addParameter(
name: string,
value?: string,
publishValueAsDefault?: boolean,
secret?: boolean): ParameterResource;
addParameterFromConfiguration(
name: string,
configurationKey: string,
secret?: boolean): ParameterResource;
addParameterWithGeneratedValue(
name: string,
value: GenerateParameterDefault,
secret?: boolean,
persist?: boolean): ParameterResource;
addProject(
name: string,
projectPath: string,
launchProfileOrOptions?: ProjectResourceOptions): ProjectResource;
build(): DistributedApplication;
getConfiguration(): IConfiguration;
subscribeAfterPublish(callback: (arg: AfterPublishEvent) => Promise<void>): DistributedApplicationEventSubscription;
subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise<void>): DistributedApplicationEventSubscription;
subscribeBeforePublish(callback: (arg: BeforePublishEvent) => Promise<void>): DistributedApplicationEventSubscription;
subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise<void>): DistributedApplicationEventSubscription;
tryAddEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise<void>): void;
}

Properties

property appHostDirectory string get
Directory of the project where the app host is located. Defaults to the content root if there's no project.
property environment IHostEnvironment get
Gets the Environment property
property eventing IDistributedApplicationEventing get
Eventing infrastructure for AppHost lifecycle.
property executionContext DistributedApplicationExecutionContext get
Execution context for this invocation of the AppHost.
property pipeline IDistributedApplicationPipeline get
Gets the deployment pipeline for this distributed application.
property userSecretsManager IUserSecretsManager get
Gets the service for managing user secrets.

Methods

method addConnectionString builder
Adds a connection string resource
addConnectionString(
name: string,
environmentVariableNameOrExpression?: ReferenceExpression): IResourceWithConnectionString
name string
environmentVariableNameOrExpression ReferenceExpression optional
IResourceWithConnectionString
method addContainer builder
Adds a container resource to the application.
addContainer(
name: string,
image: AddContainerOptions): ContainerResource
name string
image AddContainerOptions
ContainerResource
method addContainerRegistry builder
Adds a container registry resource
addContainerRegistry(
name: string,
endpoint: ParameterResource,
repository?: ParameterResource): ContainerRegistryResource
name string
endpoint ParameterResource
repository ParameterResource optional
ContainerRegistryResource
method addCSharpApp builder
Adds a C# application resource
addCSharpApp(
name: string,
path: string,
options?: ProjectResourceOptions): CSharpAppResource
name string
path string
options ProjectResourceOptions optional
CSharpAppResource
method addDockerfile builder
Adds a Dockerfile to the application model that can be treated like a container resource.
addDockerfile(
name: string,
contextPath: string,
dockerfilePath?: string,
stage?: string): ContainerResource
name string
contextPath string
dockerfilePath string optional
stage string optional
ContainerResource
method addDockerfileBuilder builder
Adds a container resource built from a programmatically generated Dockerfile
addDockerfileBuilder(name: string, contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise<void>, stage?: string): ContainerResource
name string
contextPath string
callback (arg: DockerfileBuilderCallbackContext) => Promise<void>
stage string optional
ContainerResource
method addDockerfileFactory builder
Adds a Dockerfile to the application model that can be treated like a container resource, with the Dockerfile content generated by an asynchronous factory function.
addDockerfileFactory(name: string, contextPath: string, dockerfileFactory: (arg: DockerfileFactoryContext) => Promise<string>, stage?: string): ContainerResource
name string
contextPath string
dockerfileFactory (arg: DockerfileFactoryContext) => Promise<string>
stage string optional
ContainerResource
method addDotnetTool builder
Adds a .NET tool resource to the application model.
addDotnetTool(
name: string,
packageId: string): DotnetToolResource
name string
packageId string
DotnetToolResource
Adds an ATS-friendly eventing subscriber callback to the distributed-application builder.
addEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise<void>): void
subscribe (arg: EventingSubscriberRegistrationContext) => Promise<void>
method addExecutable builder
Adds an executable resource to the application model.
addExecutable(
name: string,
command: string,
workingDirectory: string,
args: string[]): ExecutableResource
name string
command string
workingDirectory string
args string[]
ExecutableResource
method addExternalService builder
Adds an external service resource
addExternalService(
name: string,
url: ParameterResource): ExternalServiceResource
name string
url ParameterResource
ExternalServiceResource
method addParameter builder
Adds a parameter resource
addParameter(
name: string,
value?: string,
publishValueAsDefault?: boolean,
secret?: boolean): ParameterResource
name string
value string optional
publishValueAsDefault boolean optional = False
secret boolean optional = False
ParameterResource
Adds a parameter resource to the application, with a value coming from configuration.
addParameterFromConfiguration(
name: string,
configurationKey: string,
secret?: boolean): ParameterResource
name string
configurationKey string
secret boolean optional = False
ParameterResource
Adds a parameter with a generated default value
addParameterWithGeneratedValue(
name: string,
value: GenerateParameterDefault,
secret?: boolean,
persist?: boolean): ParameterResource
name string
value GenerateParameterDefault
secret boolean optional = False
persist boolean optional = False
ParameterResource
method addProject builder
Adds a .NET project resource
addProject(
name: string,
projectPath: string,
launchProfileOrOptions?: ProjectResourceOptions): ProjectResource
name string
projectPath string
launchProfileOrOptions ProjectResourceOptions optional
ProjectResource
method build
Builds the distributed application
build(): DistributedApplication
DistributedApplication
Gets the application configuration.
getConfiguration(): IConfiguration
IConfiguration
Subscribes to the AfterPublish event, which fires after the application is published.
subscribeAfterPublish(callback: (arg: AfterPublishEvent) => Promise<void>): DistributedApplicationEventSubscription
callback (arg: AfterPublishEvent) => Promise<void>
DistributedApplicationEventSubscription
Subscribes to the AfterResourcesCreated event, which fires after all resources are created.
subscribeAfterResourcesCreated(callback: (arg: AfterResourcesCreatedEvent) => Promise<void>): DistributedApplicationEventSubscription
callback (arg: AfterResourcesCreatedEvent) => Promise<void>
DistributedApplicationEventSubscription
Subscribes to the BeforePublish event, which fires before the application is published.
subscribeBeforePublish(callback: (arg: BeforePublishEvent) => Promise<void>): DistributedApplicationEventSubscription
callback (arg: BeforePublishEvent) => Promise<void>
DistributedApplicationEventSubscription
Subscribes to the BeforeStart event, which fires before the application starts.
subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise<void>): DistributedApplicationEventSubscription
callback (arg: BeforeStartEvent) => Promise<void>
DistributedApplicationEventSubscription
Attempts to add an ATS-friendly eventing subscriber callback to the distributed-application builder.
tryAddEventingSubscriber(subscribe: (arg: EventingSubscriberRegistrationContext) => Promise<void>): void
subscribe (arg: EventingSubscriberRegistrationContext) => Promise<void>