Skip to content
Docs Try Aspire

ExecutionConfigurationBuilder Methods

Class Methods 3 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)
{
// ...
}
}
gatherer IExecutionConfigurationGatherer The configuration gatherer to add.
IExecutionConfigurationBuilder The 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))
{
// ...
}
}
executionContext DistributedApplicationExecutionContext The distributed application execution context.
resourceLogger ILogger? optional A logger instance for the resource. If none is provided, a default logger will be used.
cancellationToken CancellationToken optional A 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)
{
// ...
}
}
resource IResource The 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}");
}