Skip to content
Docs Try Aspire

ParameterResourceBuilderExtensions Methods

Class Methods 13 members
Provides extension methods for adding parameter resources to an application.
AddConnectionString(IDistributedApplicationBuilder, string, string?) Section titled AddConnectionString(IDistributedApplicationBuilder, string, string?) extension IResourceBuilder<IResourceWithConnectionString>
Adds a parameter to the distributed application but wrapped in a resource with a connection string for use with ResourceBuilderExtensions.WithReference
public static class ParameterResourceBuilderExtensions
{
public static IResourceBuilder<IResourceWithConnectionString> AddConnectionString(
this IDistributedApplicationBuilder builder,
string name,
string? environmentVariableName = null)
{
// ...
}
}
builder IDistributedApplicationBuilder Distributed application builder
name string Name of parameter resource. The value of the connection string is read from the "ConnectionStrings:{resourcename}" configuration section, for example in appsettings.json or user secrets
environmentVariableName string? optional Environment variable name to set when WithReference is used.
IResourceBuilder<IResourceWithConnectionString> Resource builder for the parameter.
AddParameter(IDistributedApplicationBuilder, string, bool) Section titled AddParameter(IDistributedApplicationBuilder, string, bool) extension IResourceBuilder<ParameterResource>
Adds a parameter resource to the application.
public static class ParameterResourceBuilderExtensions
{
public static IResourceBuilder<ParameterResource> AddParameter(
this IDistributedApplicationBuilder builder,
string name,
bool secret = false)
{
// ...
}
}
builder IDistributedApplicationBuilder Distributed application builder
name string Name of parameter resource
secret bool optional Optional flag indicating whether the parameter should be regarded as secret.
IResourceBuilder<ParameterResource> Resource builder for the parameter.
AddParameter(IDistributedApplicationBuilder, string, string, bool, bool) Section titled AddParameter(IDistributedApplicationBuilder, string, string, bool, bool) extension IResourceBuilder<ParameterResource>
Adds a parameter resource to the application with a given value.
public static class ParameterResourceBuilderExtensions
{
public static IResourceBuilder<ParameterResource> AddParameter(
this IDistributedApplicationBuilder builder,
string name,
string value,
bool publishValueAsDefault = false,
bool secret = false)
{
// ...
}
}
builder IDistributedApplicationBuilder Distributed application builder
name string Name of parameter resource
value string A string value to use for the parameter
publishValueAsDefault bool optional Indicates whether the value should be published to the manifest. This is not meant for sensitive data.
secret bool optional Optional flag indicating whether the parameter should be regarded as secret.
IResourceBuilder<ParameterResource> Resource builder for the parameter.
publishValueAsDefault and secret are mutually exclusive.
AddParameter(IDistributedApplicationBuilder, string, Func<string>, bool, bool) Section titled AddParameter(IDistributedApplicationBuilder, string, Func<string>, bool, bool) extension IResourceBuilder<ParameterResource>
Adds a parameter resource to the application with a value coming from a callback function.
public static class ParameterResourceBuilderExtensions
{
public static IResourceBuilder<ParameterResource> AddParameter(
this IDistributedApplicationBuilder builder,
string name,
Func<string> valueGetter,
bool publishValueAsDefault = false,
bool secret = false)
{
// ...
}
}
builder IDistributedApplicationBuilder Distributed application builder
name string Name of parameter resource
valueGetter Func<string> A callback function that returns the value of the parameter
publishValueAsDefault bool optional Indicates whether the value should be published to the manifest. This is not meant for sensitive data.
secret bool optional Optional flag indicating whether the parameter should be regarded as secret.
IResourceBuilder<ParameterResource> Resource builder for the parameter.
publishValueAsDefault and secret are mutually exclusive.
AddParameter(IDistributedApplicationBuilder, string, ParameterDefault, bool, bool) Section titled AddParameter(IDistributedApplicationBuilder, string, ParameterDefault, bool, bool) extension IResourceBuilder<ParameterResource>
Adds a parameter resource to the application, with a value coming from a ParameterDefault if not supplied from configuration.
public static class ParameterResourceBuilderExtensions
{
public static IResourceBuilder<ParameterResource> AddParameter(
this IDistributedApplicationBuilder builder,
string name,
ParameterDefault value,
bool secret = false,
bool persist = false)
{
// ...
}
}
builder IDistributedApplicationBuilder Distributed application builder
name string Name of parameter resource
value ParameterDefault A ParameterDefault that is used to provide the parameter value if a value is not present in configuration
secret bool optional Optional flag indicating whether the parameter should be regarded as secret.
persist bool optional Persist the value to the app host project's user secrets store. This is typically done when the value is generated, so that it stays stable across runs. This is only relevant when DistributedApplicationExecutionContext.IsRunMode is true
IResourceBuilder<ParameterResource> Resource builder for the parameter.
AddParameterFromConfiguration(IDistributedApplicationBuilder, string, string, bool) Section titled AddParameterFromConfiguration(IDistributedApplicationBuilder, string, string, bool) extension IResourceBuilder<ParameterResource>
Adds a parameter resource to the application, with a value coming from configuration.
public static class ParameterResourceBuilderExtensions
{
public static IResourceBuilder<ParameterResource> AddParameterFromConfiguration(
this IDistributedApplicationBuilder builder,
string name,
string configurationKey,
bool secret = false)
{
// ...
}
}
builder IDistributedApplicationBuilder Distributed application builder
name string Name of parameter resource
configurationKey string Configuration key used to get the value of the parameter
secret bool optional Optional flag indicating whether the parameter should be regarded as secret.
IResourceBuilder<ParameterResource> Resource builder for the parameter.
ConfigureConnectionStringManifestPublisher(IResourceBuilder<IResourceWithConnectionString>) Section titled ConfigureConnectionStringManifestPublisher(IResourceBuilder<IResourceWithConnectionString>) static
Configures the manifest writer for this resource to be a parameter resource.
public static class ParameterResourceBuilderExtensions
{
public static void ConfigureConnectionStringManifestPublisher(
IResourceBuilder<IResourceWithConnectionString> builder)
{
// ...
}
}
builder IResourceBuilder<IResourceWithConnectionString> The ApplicationModel.IResourceBuilder`1.
CreateDefaultPasswordParameter(IDistributedApplicationBuilder, string, bool, bool, bool, bool, int, int, int, int) Section titled CreateDefaultPasswordParameter(IDistributedApplicationBuilder, string, bool, bool, bool, bool, int, int, int, int) static ParameterResource
Creates a default password parameter that generates a random password.
public static class ParameterResourceBuilderExtensions
{
public static ParameterResource CreateDefaultPasswordParameter(
IDistributedApplicationBuilder builder,
string name,
bool lower = true,
bool upper = true,
bool numeric = true,
bool special = true,
int minLower = 0,
int minUpper = 0,
int minNumeric = 0,
int minSpecial = 0)
{
// ...
}
}
builder IDistributedApplicationBuilder Distributed application builder
name string Name of parameter resource
lower bool optional true if lowercase alphabet characters should be included; otherwise, false.
upper bool optional true if uppercase alphabet characters should be included; otherwise, false.
numeric bool optional true if numeric characters should be included; otherwise, false.
special bool optional true if special characters should be included; otherwise, false.
minLower int optional The minimum number of lowercase characters in the result.
minUpper int optional The minimum number of uppercase characters in the result.
minNumeric int optional The minimum number of numeric characters in the result.
minSpecial int optional The minimum number of special characters in the result.
To ensure the generated password has enough entropy, see the remarks in GenerateParameterDefault. The value will be saved to the app host project's user secrets store when DistributedApplicationExecutionContext.IsRunMode is true.
CreateGeneratedParameter(IDistributedApplicationBuilder, string, bool, GenerateParameterDefault) Section titled CreateGeneratedParameter(IDistributedApplicationBuilder, string, bool, GenerateParameterDefault) static ParameterResource
Creates a new ParameterResource that has a generated value using the parameterDefault.
public static class ParameterResourceBuilderExtensions
{
public static ParameterResource CreateGeneratedParameter(
IDistributedApplicationBuilder builder,
string name,
bool secret,
GenerateParameterDefault parameterDefault)
{
// ...
}
}
builder IDistributedApplicationBuilder Distributed application builder
name string Name of parameter resource
secret bool Flag indicating whether the parameter should be regarded as secret.
parameterDefault GenerateParameterDefault The GenerateParameterDefault that describes how the parameter's value should be generated.
The value will be saved to the app host project's user secrets store when DistributedApplicationExecutionContext.IsRunMode is true.
CreateParameter(IDistributedApplicationBuilder, string, bool) Section titled CreateParameter(IDistributedApplicationBuilder, string, bool) static ParameterResource
Creates a new ParameterResource.
public static class ParameterResourceBuilderExtensions
{
public static ParameterResource CreateParameter(
IDistributedApplicationBuilder builder,
string name,
bool secret)
{
// ...
}
}
builder IDistributedApplicationBuilder Distributed application builder
name string Name of parameter resource
secret bool Flag indicating whether the parameter should be regarded as secret.
The value will be saved to the app host project's user secrets store when DistributedApplicationExecutionContext.IsRunMode is true.
PublishAsConnectionString(IResourceBuilder<T>) Section titled PublishAsConnectionString(IResourceBuilder<T>) extension IResourceBuilder<T>
Changes the resource to be published as a connection string reference in the manifest.
public static class ParameterResourceBuilderExtensions
{
public static IResourceBuilder<T> PublishAsConnectionString<T>(
this IResourceBuilder<T> builder)
{
// ...
}
}
builder IResourceBuilder<T> The resource builder.
IResourceBuilder<T> The configured ApplicationModel.IResourceBuilder`1.
WithCustomInput(IResourceBuilder<ParameterResource>, Func<ParameterResource, InteractionInput>) Section titled WithCustomInput(IResourceBuilder<ParameterResource>, Func<ParameterResource, InteractionInput>) extension IResourceBuilder<ParameterResource>
Sets a custom input generator function for the parameter resource.
public static class ParameterResourceBuilderExtensions
{
public static IResourceBuilder<ParameterResource> WithCustomInput(
this IResourceBuilder<ParameterResource> builder,
Func<ParameterResource, InteractionInput> createInput)
{
// ...
}
}
builder IResourceBuilder<ParameterResource> Resource builder for the parameter.
createInput Func<ParameterResource, InteractionInput> Function to customize the input for the parameter.
IResourceBuilder<ParameterResource> Resource builder for the parameter.
Use this method to customize how the input field for this parameter is rendered when its value is requested, e.g.:
builder.AddParameter("external-service-url")
.WithCustomInput(parameter => new()
{
InputType = parameter.Secret ? InputType.SecretText : InputType.Text,
Value = "https://example.com",
Label = parameter.Name,
Placeholder = $"Enter value for {parameter.Name}",
Description = parameter.Description
});
WithDescription(IResourceBuilder<ParameterResource>, string, bool) Section titled WithDescription(IResourceBuilder<ParameterResource>, string, bool) extension IResourceBuilder<ParameterResource>
Sets the description of the parameter resource.
public static class ParameterResourceBuilderExtensions
{
public static IResourceBuilder<ParameterResource> WithDescription(
this IResourceBuilder<ParameterResource> builder,
string description,
bool enableMarkdown = false)
{
// ...
}
}
builder IResourceBuilder<ParameterResource> Resource builder for the parameter.
description string The parameter description.
enableMarkdown bool optional A value indicating whether the description should be rendered as Markdown. true allows the description to contain Markdown elements such as links, text decoration and lists.
IResourceBuilder<ParameterResource> Resource builder for the parameter.