Skip to content
DocsTry Aspire
DocsTry

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

propertyappHostDirectorystringget
Directory of the project where the app host is located. Defaults to the content root if there's no project.
propertyenvironmentIHostEnvironmentget
Gets the Environment property
propertyeventingIDistributedApplicationEventingget
Eventing infrastructure for AppHost lifecycle.
propertyexecutionContextDistributedApplicationExecutionContextget
Execution context for this invocation of the AppHost.
propertypipelineIDistributedApplicationPipelineget
Gets the deployment pipeline for this distributed application.
propertyuserSecretsManagerIUserSecretsManagerget
Gets the service for managing user secrets.

Methods

methodaddConnectionStringbuilder
Adds a connection string resource
addConnectionString(
name: string,
environmentVariableNameOrExpression?: ReferenceExpression): IResourceWithConnectionString
namestring
environmentVariableNameOrExpressionReferenceExpressionoptional
IResourceWithConnectionString
methodaddContainerbuilder
Adds a container resource to the application.
addContainer(
name: string,
image: AddContainerOptions): ContainerResource
namestring
imageAddContainerOptions
ContainerResource
Adds a container registry resource
addContainerRegistry(
name: string,
endpoint: ParameterResource,
repository?: ParameterResource): ContainerRegistryResource
namestring
endpointParameterResource
repositoryParameterResourceoptional
ContainerRegistryResource
methodaddCSharpAppbuilder
Adds a C# application resource
addCSharpApp(
name: string,
path: string,
options?: ProjectResourceOptions): CSharpAppResource
namestring
pathstring
optionsProjectResourceOptionsoptional
CSharpAppResource
methodaddDockerfilebuilder
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
namestring
contextPathstring
dockerfilePathstringoptional
stagestringoptional
ContainerResource
Adds a container resource built from a programmatically generated Dockerfile
addDockerfileBuilder(name: string, contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise<void>, stage?: string): ContainerResource
namestring
contextPathstring
callback(arg: DockerfileBuilderCallbackContext) => Promise<void>
stagestringoptional
ContainerResource
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
namestring
contextPathstring
dockerfileFactory(arg: DockerfileFactoryContext) => Promise<string>
stagestringoptional
ContainerResource
methodaddDotnetToolbuilder
Adds a .NET tool resource to the application model.
addDotnetTool(
name: string,
packageId: string): DotnetToolResource
namestring
packageIdstring
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>
methodaddExecutablebuilder
Adds an executable resource to the application model.
addExecutable(
name: string,
command: string,
workingDirectory: string,
args: string[]): ExecutableResource
namestring
commandstring
workingDirectorystring
argsstring[]
ExecutableResource
methodaddExternalServicebuilder
Adds an external service resource
addExternalService(
name: string,
url: ParameterResource): ExternalServiceResource
namestring
urlParameterResource
ExternalServiceResource
methodaddParameterbuilder
Adds a parameter resource
addParameter(
name: string,
value?: string,
publishValueAsDefault?: boolean,
secret?: boolean): ParameterResource
namestring
valuestringoptional
publishValueAsDefaultbooleanoptional= False
secretbooleanoptional= False
ParameterResource
Adds a parameter resource to the application, with a value coming from configuration.
addParameterFromConfiguration(
name: string,
configurationKey: string,
secret?: boolean): ParameterResource
namestring
configurationKeystring
secretbooleanoptional= False
ParameterResource
Adds a parameter with a generated default value
addParameterWithGeneratedValue(
name: string,
value: GenerateParameterDefault,
secret?: boolean,
persist?: boolean): ParameterResource
namestring
valueGenerateParameterDefault
secretbooleanoptional= False
persistbooleanoptional= False
ParameterResource
methodaddProjectbuilder
Adds a .NET project resource
addProject(
name: string,
projectPath: string,
launchProfileOrOptions?: ProjectResourceOptions): ProjectResource
namestring
projectPathstring
launchProfileOrOptionsProjectResourceOptionsoptional
ProjectResource
methodbuild
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>