ParameterResourceBuilderExtensions Methods
AddConnectionString(IDistributedApplicationBuilder, string, string?) Section titled AddConnectionString(IDistributedApplicationBuilder, string, string?)extensionIResourceBuilder<IResourceWithConnectionString> ResourceBuilderExtensions.WithReference public static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<IResourceWithConnectionString> AddConnectionString( this IDistributedApplicationBuilder builder, string name, string? environmentVariableName = null) { // ... }}Parameters
builderInamestringName of parameter resource. The value of the connection string is read from the "ConnectionStrings:{resourcename}" configuration section, for example in appsettings.json or user secretsenvironmentVariableName string?optionalEnvironment variable name to set when WithReference is used.Returns
IResourceBuilder<IResourceWithConnectionString> Resource builder for the parameter.Exceptions
AddParameter(IDistributedApplicationBuilder, string, bool) Section titled AddParameter(IDistributedApplicationBuilder, string, bool)extensionIResourceBuilder<ParameterResource> public static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<ParameterResource> AddParameter( this IDistributedApplicationBuilder builder, string name, bool secret = false) { // ... }}Parameters
builderInamestringName of parameter resourcesecretbooloptionalOptional flag indicating whether the parameter should be regarded as secret.Returns
IResourceBuilder<ParameterResource> Resource builder for the parameter.Exceptions
AddParameter(IDistributedApplicationBuilder, string, string, bool, bool) Section titled AddParameter(IDistributedApplicationBuilder, string, string, bool, bool)extensionIResourceBuilder<ParameterResource> public static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<ParameterResource> AddParameter( this IDistributedApplicationBuilder builder, string name, string value, bool publishValueAsDefault = false, bool secret = false) { // ... }}Parameters
builderInamestringName of parameter resourcevaluestringA string value to use for the parameterpublishValueAsDefault booloptionalIndicates 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.Returns
IResourceBuilder<ParameterResource> Resource builder for the parameter.Remarks
AddParameter(IDistributedApplicationBuilder, string, Func<string>, bool, bool) Section titled AddParameter(IDistributedApplicationBuilder, string, Func<string>, bool, bool)extensionIResourceBuilder<ParameterResource> public static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<ParameterResource> AddParameter( this IDistributedApplicationBuilder builder, string name, Func<string> valueGetter, bool publishValueAsDefault = false, bool secret = false) { // ... }}Parameters
builderInamestringName of parameter resourcevalueGetter Func<string> A callback function that returns the value of the parameterpublishValueAsDefault booloptionalIndicates 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.Returns
IResourceBuilder<ParameterResource> Resource builder for the parameter.Remarks
This method is not available in polyglot AppHosts. Use the overload with a string value instead.
AddParameter(IDistributedApplicationBuilder, string, ParameterDefault, bool, bool) Section titled AddParameter(IDistributedApplicationBuilder, string, ParameterDefault, bool, bool)extensionIResourceBuilder<ParameterResource> 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) { // ... }}Parameters
builderInamestringName of parameter resourcevalueParameterParameterDefault that is used to provide the parameter value if a value is not present in configurationsecretbooloptionalOptional flag indicating whether the parameter should be regarded as secret.persistbooloptionalPersist the value to the AppHost 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 trueReturns
IResourceBuilder<ParameterResource> Resource builder for the parameter.Remarks
AddParameterFromConfiguration(IDistributedApplicationBuilder, string, string, bool) Section titled AddParameterFromConfiguration(IDistributedApplicationBuilder, string, string, bool)extensionIResourceBuilder<ParameterResource> public static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<ParameterResource> AddParameterFromConfiguration( this IDistributedApplicationBuilder builder, string name, string configurationKey, bool secret = false) { // ... }}Parameters
builderInamestringName of parameter resourceconfigurationKey stringConfiguration key used to get the value of the parametersecretbooloptionalOptional flag indicating whether the parameter should be regarded as secret.Returns
IResourceBuilder<ParameterResource> Resource builder for the parameter.AsOptional(IResourceBuilder<ParameterResource>) Section titled AsOptional(IResourceBuilder<ParameterResource>)extensionIResourceBuilder<ParameterResource> public static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<ParameterResource> AsOptional( this IResourceBuilder<ParameterResource> builder) { // ... }}Parameters
builderIResourceBuilder<ParameterResource> Resource builder for the parameter.Returns
IResourceBuilder<ParameterResource> The configured resource builder.Remarks
null. The manifest publisher does not currently support optional parameters and throws a DistributedApplicationException . AsRequired(IResourceBuilder<ParameterResource>) Section titled AsRequired(IResourceBuilder<ParameterResource>)extensionIResourceBuilder<ParameterResource> public static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<ParameterResource> AsRequired( this IResourceBuilder<ParameterResource> builder) { // ... }}Parameters
builderIResourceBuilder<ParameterResource> Resource builder for the parameter.Returns
IResourceBuilder<ParameterResource> The configured resource builder.Remarks
ParameterResourceBuilderExtensions.AsOptional . ConfigureConnectionStringManifestPublisher(IResourceBuilder<IResourceWithConnectionString>) Section titled ConfigureConnectionStringManifestPublisher(IResourceBuilder<IResourceWithConnectionString>)staticpublic static class ParameterResourceBuilderExtensions{ public static void ConfigureConnectionStringManifestPublisher( IResourceBuilder<IResourceWithConnectionString> builder) { // ... }}Parameters
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)staticParameterpublic 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) { // ... }}Parameters
builderInamestringName of parameter resourcelowerbooloptionaltrue 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.minLower intoptionalThe minimum number of lowercase characters in the result.minUpper intoptionalThe minimum number of uppercase characters in the result.minNumeric intoptionalThe minimum number of numeric characters in the result.minSpecial intoptionalThe minimum number of special characters in the result.Returns
ParameterResource The created ParameterResource .Remarks
GenerateParameterDefault . The value will be saved to the AppHost project's user secrets store when DistributedApplicationExecutionContext.IsRunMode is true. CreateGeneratedParameter(IDistributedApplicationBuilder, string, bool, GenerateParameterDefault) Section titled CreateGeneratedParameter(IDistributedApplicationBuilder, string, bool, GenerateParameterDefault)staticParameterParameterResource that has a generated value using the parameterDefault . public static class ParameterResourceBuilderExtensions{ public static ParameterResource CreateGeneratedParameter( IDistributedApplicationBuilder builder, string name, bool secret, GenerateParameterDefault parameterDefault) { // ... }}Parameters
builderInamestringName of parameter resourcesecretboolFlag indicating whether the parameter should be regarded as secret.parameterDefault GenerateGenerateParameterDefault that describes how the parameter's value should be generated.Returns
ParameterResource The created ParameterResource .Remarks
DistributedApplicationExecutionContext.IsRunMode is true. CreateParameter(IDistributedApplicationBuilder, string, bool) Section titled CreateParameter(IDistributedApplicationBuilder, string, bool)staticParameterParameterResource . public static class ParameterResourceBuilderExtensions{ public static ParameterResource CreateParameter( IDistributedApplicationBuilder builder, string name, bool secret) { // ... }}Parameters
builderInamestringName of parameter resourcesecretboolFlag indicating whether the parameter should be regarded as secret.Returns
ParameterResource The created ParameterResource .Remarks
DistributedApplicationExecutionContext.IsRunMode is true. CreateParameter(IConfiguration, string, bool) Section titled CreateParameter(IConfiguration, string, bool)staticParameterpublic static class ParameterResourceBuilderExtensions{ public static ParameterResource CreateParameter( IConfiguration configuration, string name, bool secret) { // ... }}Parameters
configurationIConfiguration The configuration containing the parameter value.namestringThe parameter resource name. Values are read from Parameters:{name} .secretboolWhether the parameter contains a secret.Returns
ParameterResource A parameter resource that can be referenced without adding it to the application model.Exceptions
ArgumentNullExceptionAn argument is null.CreateParameter(IConfiguration, string, bool, string?) Section titled CreateParameter(IConfiguration, string, bool, string?)staticParameterpublic static class ParameterResourceBuilderExtensions{ public static ParameterResource CreateParameter( IConfiguration configuration, string name, bool secret, string? defaultValue) { // ... }}Parameters
configurationIConfiguration The configuration containing the parameter value.namestringThe parameter resource name.secretboolWhether the parameter contains a secret.defaultValue string?The published default, or null to require an input.Returns
ParameterResource A parameter resource using the standard parameter configuration lookup.Exceptions
ArgumentNullExceptionAn argument is null.PublishAsConnectionString(IResourceBuilder<T>) Section titled PublishAsConnectionString(IResourceBuilder<T>)extensionIpublic static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<T> PublishAsConnectionString<T>( this IResourceBuilder<T> builder) { // ... }}Parameters
builderIReturns
IResourceBuilder<T> The configured ApplicationModel.IResourceBuilder`1 .Remarks
WithCustomInput(IResourceBuilder<ParameterResource>, Func<ParameterResource, InteractionInput>) Section titled WithCustomInput(IResourceBuilder<ParameterResource>, Func<ParameterResource, InteractionInput>)extensionIResourceBuilder<ParameterResource> public static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<ParameterResource> WithCustomInput( this IResourceBuilder<ParameterResource> builder, Func<ParameterResource, InteractionInput> createInput) { // ... }}Parameters
builderIResourceBuilder<ParameterResource> Resource builder for the parameter.createInput Func<ParameterResource, InteractionInput> Function to customize the input for the parameter.Returns
IResourceBuilder<ParameterResource> Resource builder for the parameter.Remarks
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 AppHosts.
WithDescription(IResourceBuilder<ParameterResource>, string, bool) Section titled WithDescription(IResourceBuilder<ParameterResource>, string, bool)extensionIResourceBuilder<ParameterResource> public static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<ParameterResource> WithDescription( this IResourceBuilder<ParameterResource> builder, string description, bool enableMarkdown = false) { // ... }}Parameters
builderIResourceBuilder<ParameterResource> Resource builder for the parameter.descriptionstringThe parameter description.enableMarkdown booloptional 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. Returns
IResourceBuilder<ParameterResource> Resource builder for the parameter.