Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

DistributedApplicationBuilder

Interface
📦 Aspire.Hosting v17.0.0

A builder for creating instances of DistributedApplication.

type DistributedApplicationBuilder interface{}

Properties

propertyAppHostDirectorystringget
Directory of the project where the AppHost is located. Defaults to the content root if there's no project.
AppHostDirectory() (string, error)
propertyEnvironmentHostEnvironmentget
Gets the Environment property
Environment() HostEnvironment
propertyEventingDistributedApplicationEventingget
Eventing infrastructure for AppHost lifecycle.
Eventing() DistributedApplicationEventing
propertyExecutionContextDistributedApplicationExecutionContextget
Execution context for this invocation of the AppHost.
ExecutionContext() DistributedApplicationExecutionContext
propertyPipelineDistributedApplicationPipelineget
Gets the deployment pipeline for this distributed application.
Pipeline() DistributedApplicationPipeline
propertyUserSecretsManagerUserSecretsManagerget
Gets the service for managing user secrets.
UserSecretsManager() UserSecretsManager

Methods

methodAddConnectionStringbuilder
Adds a connection string resource
AddConnectionString(
name string,
options ...*AddConnectionStringOptions,
) ResourceWithConnectionString
namestring
options...*AddConnectionStringOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddConnectionStringOptions argument.

EnvironmentVariableNameOrExpressionany
ResourceWithConnectionString

Returns a handle; failures surface later via Err().

methodAddContainerbuilder
Adds a container resource to the application.
AddContainer(
name string,
image any,
) ContainerResource
namestringThe name of the resource.
imageanyThe image name or image options for the container.
ContainerResource

The resource builder.

Returns a handle; failures surface later via Err().

Adds a container registry resource
AddContainerRegistry(
name string,
endpoint any,
options ...*AddContainerRegistryOptions,
) ContainerRegistryResource
namestring
endpointany
options...*AddContainerRegistryOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddContainerRegistryOptions argument.

Repositoryany
ContainerRegistryResource

Returns a handle; failures surface later via Err().

methodAddCSharpAppbuilder
Adds a C# application resource
AddCSharpApp(
name string,
path string,
options ...*AddCSharpAppOptions,
) CSharpAppResource
namestring
pathstring
options...*AddCSharpAppOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddCSharpAppOptions argument.

Options*ProjectResourceOptions
CSharpAppResource

Returns a handle; failures surface later via Err().

methodAddDockerfilebuilder
Adds a Dockerfile to the application model that can be treated like a container resource.
AddDockerfile(
name string,
contextPath string,
options ...*AddDockerfileOptions,
) ContainerResource
namestringThe name of the resource.
contextPathstringPath to be used as the context for the container image build.
options...*AddDockerfileOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddDockerfileOptions argument.

DockerfilePath*stringPath to the Dockerfile relative to the contextPath. Defaults to "Dockerfile" if not specified.
Stage*stringThe stage representing the image to be published in a multi-stage Dockerfile.
ContainerResource

The resource builder.

Returns a handle; failures surface later via Err().

Adds a container resource built from a programmatically generated Dockerfile
AddDockerfileBuilder(
name string,
contextPath string,
callback func(arg DockerfileBuilderCallbackContext),
options ...*AddDockerfileBuilderOptions,
) ContainerResource
namestringThe name of the resource.
contextPathstringPath to be used as the context for the container image build.
callbackfunc(arg DockerfileBuilderCallbackContext)callbackA callback that uses the DockerfileBuilder API to construct the Dockerfile.
options...*AddDockerfileBuilderOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddDockerfileBuilderOptions argument.

Stage*stringThe stage representing the image to be published in a multi-stage Dockerfile.
ContainerResource

The resource builder.

Returns a handle; failures surface later via Err().

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 func(arg DockerfileFactoryContext) string,
options ...*AddDockerfileFactoryOptions,
) ContainerResource
namestringThe name of the resource.
contextPathstringPath to be used as the context for the container image build.
dockerfileFactoryfunc(arg DockerfileFactoryContext) stringcallbackAn asynchronous function that returns the Dockerfile content as a string.
options...*AddDockerfileFactoryOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddDockerfileFactoryOptions argument.

Stage*stringThe stage representing the image to be published in a multi-stage Dockerfile.
ContainerResource

The resource builder.

Returns a handle; failures surface later via Err().

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

The resource builder.

Returns a handle; failures surface later via Err().

Adds an ATS-friendly eventing subscriber callback to the distributed-application builder.
AddEventingSubscriber(subscribe func(arg EventingSubscriberRegistrationContext)) error
subscribefunc(arg EventingSubscriberRegistrationContext)callbackThe callback that registers the event subscriptions.
error

Returns error.

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.
args[]stringThe arguments to the executable.
ExecutableResource

The resource builder.

Returns a handle; failures surface later via Err().

methodAddExternalServicebuilder
Adds an external service resource
AddExternalService(
name string,
url any,
) ExternalServiceResource
namestring
urlany
ExternalServiceResource

Returns a handle; failures surface later via Err().

Adds a custom health check callback to the distributed-application builder.
AddHealthCheck(
name string,
check func(...any) *HealthCheckResult,
) error
namestringThe health check registration name.
checkfunc(...any) *HealthCheckResultcallbackThe callback that evaluates the health check.
error

Returns error.

methodAddParameterbuilder
Adds a parameter resource
AddParameter(
name string,
options ...*AddParameterOptions,
) ParameterResource
namestring
options...*AddParameterOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddParameterOptions argument.

Value*string
PublishValueAsDefault*bool
Secret*bool
ParameterResource

Returns a handle; failures surface later via Err().

Adds a parameter resource to the application, with a value coming from configuration.
AddParameterFromConfiguration(
name string,
configurationKey string,
options ...*AddParameterFromConfigurationOptions,
) ParameterResource
namestringName of parameter resource
configurationKeystringConfiguration key used to get the value of the parameter
options...*AddParameterFromConfigurationOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddParameterFromConfigurationOptions argument.

Secret*boolOptional flag indicating whether the parameter should be regarded as secret.
ParameterResource

Resource builder for the parameter.

Returns a handle; failures surface later via Err().

Adds a parameter with a generated default value
AddParameterWithGeneratedValue(
name string,
value *GenerateParameterDefault,
options ...*AddParameterWithGeneratedValueOptions,
) ParameterResource
namestring
value*GenerateParameterDefault
options...*AddParameterWithGeneratedValueOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddParameterWithGeneratedValueOptions argument.

Secret*bool
Persist*bool
ParameterResource

Returns a handle; failures surface later via Err().

methodAddProjectbuilder
Adds a .NET project resource
AddProject(
name string,
projectPath string,
options ...*AddProjectOptions,
) ProjectResource
namestring
projectPathstring
options...*AddProjectOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddProjectOptions argument.

LaunchProfileOrOptionsany
ProjectResource

Returns a handle; failures surface later via Err().

methodBuild
Builds the distributed application
Build() (DistributedApplication, error)
(DistributedApplication, error)

A new DistributedApplication instance.

Returns (DistributedApplication, error).

Gets the application configuration.
GetConfiguration() Configuration
Configuration

The configuration handle.

Returns a handle; failures surface later via Err().

Subscribes to the AfterPublish event, which fires after the application is published.
SubscribeAfterPublish(callback func(arg AfterPublishEvent)) DistributedApplicationEventSubscription
callbackfunc(arg AfterPublishEvent)callbackA callback that receives the exported event when the event fires.
DistributedApplicationEventSubscription

A subscription handle that can be used to unsubscribe.

Returns a handle; failures surface later via Err().

Subscribes to the AfterResourcesCreated event, which fires after all resources are created.
SubscribeAfterResourcesCreated(callback func(arg AfterResourcesCreatedEvent)) DistributedApplicationEventSubscription
callbackfunc(arg AfterResourcesCreatedEvent)callbackA callback that receives the exported event when the event fires.
DistributedApplicationEventSubscription

A subscription handle that can be used to unsubscribe.

Returns a handle; failures surface later via Err().

Subscribes to the BeforePublish event, which fires before the application is published.
SubscribeBeforePublish(callback func(arg BeforePublishEvent)) DistributedApplicationEventSubscription
callbackfunc(arg BeforePublishEvent)callbackA callback that receives the exported event when the event fires.
DistributedApplicationEventSubscription

A subscription handle that can be used to unsubscribe.

Returns a handle; failures surface later via Err().

Subscribes to the BeforeStart event, which fires before the application starts.
SubscribeBeforeStart(callback func(arg BeforeStartEvent)) DistributedApplicationEventSubscription
callbackfunc(arg BeforeStartEvent)callbackA callback that receives the exported event when the event fires.
DistributedApplicationEventSubscription

A subscription handle that can be used to unsubscribe.

Returns a handle; failures surface later via Err().

Attempts to add an ATS-friendly eventing subscriber callback to the distributed-application builder.
TryAddEventingSubscriber(subscribe func(arg EventingSubscriberRegistrationContext)) error
subscribefunc(arg EventingSubscriberRegistrationContext)callbackThe callback that registers the event subscriptions.
error

Returns error.

Adds an opt-in target that checks for stale generated pipeline output.
WithOutputDiffing(options ...*WithOutputDiffingOptions) DistributedApplicationBuilder
options...*WithOutputDiffingOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithOutputDiffingOptions argument.

TargetStep*stringThe step whose completed output is compared. Defaults to publish.
DiffStepName*stringThe comparison target name. When null, uses the target name followed by -and-diff.
Description*stringAn optional description of the comparison target.
DistributedApplicationBuilder

The IDistributedApplicationBuilder for chaining.

Returns a handle; failures surface later via Err().

Applies to

This interface applies to the following types: