IDistributedApplicationBuilder

Interface
📦 Aspire.Hosting v17.0.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?: string | ReferenceExpression): IResourceWithConnectionString;
addContainer(
name: string,
image: string | AddContainerOptions): ContainerResource;
addContainerRegistry(
name: string,
endpoint: string | ParameterResource,
repository?: string | 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: string | uri | ParameterResource): ExternalServiceResource;
addHealthCheck(name: string, check: () => Promise<HealthCheckResult>): void;
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?: string | 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;
withOutputDiffing(
targetStep?: string,
diffStepName?: string,
description?: string): IDistributedApplicationBuilder;
}

Properties

propertyappHostDirectorystringget
Directory of the project where the AppHost 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?: string | ReferenceExpression): IResourceWithConnectionString
namestring
environmentVariableNameOrExpressionstring | ReferenceExpressionoptional
IResourceWithConnectionString
methodaddContainerbuilder
Adds a container resource to the application.
addContainer(
name: string,
image: string | AddContainerOptions): ContainerResource
namestringThe name of the resource.
imagestring | AddContainerOptionsThe image name or image options for the container.
ContainerResource
Adds a container registry resource
addContainerRegistry(
name: string,
endpoint: string | ParameterResource,
repository?: string | ParameterResource): ContainerRegistryResource
namestring
endpointstring | ParameterResource
repositorystring | ParameterResourceoptional
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
namestringThe name of the resource.
contextPathstringPath to be used as the context for the container image build.
dockerfilePathstringoptionalPath to the Dockerfile relative to the `contextPath`. Defaults to "Dockerfile" if not specified.
stagestringoptionalThe stage representing the image to be published in a multi-stage Dockerfile.
ContainerResource
Adds a container resource built from a programmatically generated Dockerfile
addDockerfileBuilder(name: string, contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise<void>, stage?: string): ContainerResource
namestringThe name of the resource.
contextPathstringPath to be used as the context for the container image build.
callback(arg: DockerfileBuilderCallbackContext) => Promise<void>A callback that uses the `DockerfileBuilder` API to construct the Dockerfile.
stagestringoptionalThe stage representing the image to be published in a multi-stage Dockerfile.
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
namestringThe name of the resource.
contextPathstringPath to be used as the context for the container image build.
dockerfileFactory(arg: DockerfileFactoryContext) => Promise<string>An asynchronous function that returns the Dockerfile content as a string.
stagestringoptionalThe stage representing the image to be published in a multi-stage Dockerfile.
ContainerResource
methodaddDotnetToolbuilder
Adds a .NET tool resource to the application model.
addDotnetTool(
name: string,
packageId: string): DotnetToolResource
namestringThe name of the resource.
packageIdstringThe package id of the tool.
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>The callback that registers the event subscriptions.
methodaddExecutablebuilder
Adds an executable resource to the application model.
addExecutable(
name: string,
command: string,
workingDirectory: string,
args: string[]): ExecutableResource
namestringThe name of the resource.
commandstringThe executable path. This can be a fully qualified path or a executable to run from the shell/command line.
workingDirectorystringThe working directory of the executable.
argsstring[]The arguments to the executable.
ExecutableResource
methodaddExternalServicebuilder
Adds an external service resource
addExternalService(
name: string,
url: string | uri | ParameterResource): ExternalServiceResource
namestring
urlstring | uri | ParameterResource
ExternalServiceResource
Adds a custom health check callback to the distributed-application builder.
addHealthCheck(name: string, check: () => Promise<HealthCheckResult>): void
namestringThe health check registration name.
check() => Promise<HealthCheckResult>The callback that evaluates the health check.
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
namestringName of parameter resource
configurationKeystringConfiguration key used to get the value of the parameter
secretbooleanoptional= FalseOptional flag indicating whether the parameter should be regarded as secret.
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?: string | ProjectResourceOptions): ProjectResource
namestring
projectPathstring
launchProfileOrOptionsstring | ProjectResourceOptionsoptional
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>A callback that receives the exported event when the event fires.
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>A callback that receives the exported event when the event fires.
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>A callback that receives the exported event when the event fires.
DistributedApplicationEventSubscription
Subscribes to the BeforeStart event, which fires before the application starts.
subscribeBeforeStart(callback: (arg: BeforeStartEvent) => Promise<void>): DistributedApplicationEventSubscription
callback(arg: BeforeStartEvent) => Promise<void>A callback that receives the exported event when the event fires.
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>The callback that registers the event subscriptions.
Adds an opt-in target that checks for stale generated pipeline output.
withOutputDiffing(
targetStep?: string,
diffStepName?: string,
description?: string): IDistributedApplicationBuilder
targetStepstringoptional= publishThe step whose completed output is compared. Defaults to `publish`.
diffStepNamestringoptionalThe comparison target name. When null, uses the target name followed by `-and-diff`.
descriptionstringoptionalAn optional description of the comparison target.
IDistributedApplicationBuilder