Skip to content
DocsTry Aspire
DocsTry

ParameterResourceBuilderExtensions Methods

ClassMethods13 members
Provides extension methods for adding parameter resources to an application.
AddConnectionString(IDistributedApplicationBuilder, string, string?)Section titled AddConnectionString(IDistributedApplicationBuilder, string, string?)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderDistributed application builder
namestringName 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
environmentVariableNamestring?optionalEnvironment 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)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderDistributed application builder
namestringName of parameter resource
secretbooloptionalOptional 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)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderDistributed application builder
namestringName of parameter resource
valuestringA string value to use for the parameter
publishValueAsDefaultbooloptionalIndicates whether the value should be published to the manifest. This is not meant for sensitive data.
secretbooloptionalOptional 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)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderDistributed application builder
namestringName of parameter resource
valueGetterFunc<string>A callback function that returns the value of the parameter
publishValueAsDefaultbooloptionalIndicates whether the value should be published to the manifest. This is not meant for sensitive data.
secretbooloptionalOptional flag indicating whether the parameter should be regarded as secret.
IResourceBuilder<ParameterResource>Resource builder for the parameter.
publishValueAsDefault and secret are mutually exclusive.

This method is not available in polyglot app hosts. Use the overload with a string value instead.

AddParameter(IDistributedApplicationBuilder, string, ParameterDefault, bool, bool)Section titled AddParameter(IDistributedApplicationBuilder, string, ParameterDefault, bool, bool)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderDistributed application builder
namestringName of parameter resource
valueParameterDefaultA ParameterDefault that is used to provide the parameter value if a value is not present in configuration
secretbooloptionalOptional flag indicating whether the parameter should be regarded as secret.
persistbooloptionalPersist 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.
This method is not available in polyglot app hosts. Use the overload with a string value instead.
AddParameterFromConfiguration(IDistributedApplicationBuilder, string, string, bool)Section titled AddParameterFromConfiguration(IDistributedApplicationBuilder, string, string, bool)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderDistributed application builder
namestringName of parameter resource
configurationKeystringConfiguration key used to get the value of the parameter
secretbooloptionalOptional 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)
{
// ...
}
}
builderIResourceBuilder<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)staticParameterResource
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)
{
// ...
}
}
builderIDistributedApplicationBuilderDistributed application builder
namestringName of parameter resource
lowerbooloptionaltrue if lowercase alphabet characters should be included; otherwise, false.
upperbooloptionaltrue if uppercase alphabet characters should be included; otherwise, false.
numericbooloptionaltrue if numeric characters should be included; otherwise, false.
specialbooloptionaltrue if special characters should be included; otherwise, false.
minLowerintoptionalThe minimum number of lowercase characters in the result.
minUpperintoptionalThe minimum number of uppercase characters in the result.
minNumericintoptionalThe minimum number of numeric characters in the result.
minSpecialintoptionalThe 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)staticParameterResource
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)
{
// ...
}
}
builderIDistributedApplicationBuilderDistributed application builder
namestringName of parameter resource
secretboolFlag indicating whether the parameter should be regarded as secret.
parameterDefaultGenerateParameterDefaultThe 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)staticParameterResource
Creates a new ParameterResource.
public static class ParameterResourceBuilderExtensions
{
public static ParameterResource CreateParameter(
IDistributedApplicationBuilder builder,
string name,
bool secret)
{
// ...
}
}
builderIDistributedApplicationBuilderDistributed application builder
namestringName of parameter resource
secretboolFlag 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>)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<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>)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<ParameterResource>Resource builder for the parameter.
createInputFunc<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
});

This method is not available in polyglot app hosts.

WithDescription(IResourceBuilder<ParameterResource>, string, bool)Section titled WithDescription(IResourceBuilder<ParameterResource>, string, bool)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<ParameterResource>Resource builder for the parameter.
descriptionstringThe parameter description.
enableMarkdownbooloptional 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.