Skip to content
DocsTry Aspire
DocsTry

ExecutionConfigurationBuilder Methods

ClassMethods3 members
Provides a builder for constructing an IExecutionConfigurationResult for a specific resource in the distributed application model. This resolves command line arguments and environment variables and potentially additional metadata through registered gatherers.
Adds a configuration gatherer to the builder.
public sealed class ExecutionConfigurationBuilder
{
public IExecutionConfigurationBuilder AddExecutionConfigurationGatherer(
IExecutionConfigurationGatherer gatherer)
{
// ...
}
}
gathererIExecutionConfigurationGathererThe configuration gatherer to add.
IExecutionConfigurationBuilderThe current instance of the builder.
Builds the processed resource configuration (resolved arguments and environment variables).
public sealed class ExecutionConfigurationBuilder
{
public Task<IExecutionConfigurationResult> BuildAsync(
DistributedApplicationExecutionContext executionContext,
ILogger? resourceLogger = null,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
executionContextDistributedApplicationExecutionContextThe distributed application execution context.
resourceLoggerILogger?optionalA logger instance for the resource. If none is provided, a default logger will be used.
cancellationTokenCancellationTokenoptionalA cancellation token.
Task<IExecutionConfigurationResult>The resource configuration result. Any exceptions that occurred while processing are available via the IExecutionConfigurationResult.Exception property.
Creates a new instance of IExecutionConfigurationBuilder.
public sealed class ExecutionConfigurationBuilder
{
public static IExecutionConfigurationBuilder Create(
IResource resource)
{
// ...
}
}
resourceIResourceThe resource to build the configuration for.

This method is useful for building resource execution configurations (command line arguments and environment variables) in a fluent manner. Individual configuration sources can be added to the builder before finalizing the configuration to allow only supported configuration sources to be applied in a given execution context (run vs. publish, etc).

In particular, this is used to allow certificate-related features to contribute to the final config, but only in execution contexts where they're supported.

var resolvedConfiguration = await ExecutionConfigurationBuilder
.Create(myResource)
.WithArgumentsConfig()
.WithEnvironmentVariablesConfig()
.BuildAsync(executionContext)
.ConfigureAwait(false);
foreach (var argument in resolvedConfiguration.Arguments)
{
Console.WriteLine($"Argument: {argument.Value}");
}