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.WithReferencepublic static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<IResourceWithConnectionString> AddConnectionString( this IDistributedApplicationBuilder builder, string name, string? environmentVariableName = null) { // ... }}Parameters
builderIDistributedApplicationBuilderDistributed application buildernamestringName of parameter resource. The value of the connection string is read from the "ConnectionStrings:{resourcename}" configuration section, for example in appsettings.json or user secretsenvironmentVariableNamestring?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> Adds a parameter resource to the application.
public static class ParameterResourceBuilderExtensions{ public static IResourceBuilder<ParameterResource> AddParameter( this IDistributedApplicationBuilder builder, string name, bool secret = false) { // ... }}Parameters
builderIDistributedApplicationBuilderDistributed application buildernamestringName 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> 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) { // ... }}Parameters
builderIDistributedApplicationBuilderDistributed application buildernamestringName of parameter resourcevaluestringA string value to use for the parameterpublishValueAsDefaultbooloptionalIndicates 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
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) { // ... }}Parameters
builderIDistributedApplicationBuilderDistributed application buildernamestringName of parameter resourcevalueGetterFunc<string>A callback function that returns the value of the parameterpublishValueAsDefaultbooloptionalIndicates 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
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) { // ... }}Parameters
builderIDistributedApplicationBuilderDistributed application buildernamestringName of parameter resourcevalueParameterDefaultA ParameterDefault 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 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 trueReturns
IResourceBuilder<ParameterResource>Resource builder for the parameter.Remarks
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) { // ... }}Parameters
builderIDistributedApplicationBuilderDistributed application buildernamestringName of parameter resourceconfigurationKeystringConfiguration 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.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) { // ... }}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)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) { // ... }}Parameters
builderIDistributedApplicationBuilderDistributed application buildernamestringName 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.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.Returns
ParameterResourceThe created ParameterResource.Remarks
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) { // ... }}Parameters
builderIDistributedApplicationBuilderDistributed application buildernamestringName of parameter resourcesecretboolFlag indicating whether the parameter should be regarded as secret.parameterDefaultGenerateParameterDefaultThe GenerateParameterDefault that describes how the parameter's value should be generated.Returns
ParameterResourceThe created ParameterResource.Remarks
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) { // ... }}Parameters
builderIDistributedApplicationBuilderDistributed application buildernamestringName of parameter resourcesecretboolFlag indicating whether the parameter should be regarded as secret.Returns
ParameterResourceThe created ParameterResource.Remarks
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) { // ... }}Parameters
builderIResourceBuilder<T>The resource builder.Returns
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) { // ... }}Parameters
builderIResourceBuilder<ParameterResource>Resource builder for the parameter.createInputFunc<ParameterResource, InteractionInput>Function to customize the input for the parameter.Returns
IResourceBuilder<ParameterResource>Resource builder for the parameter.Remarks
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) { // ... }}Parameters
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. Returns
IResourceBuilder<ParameterResource>Resource builder for the parameter.