Skip to content

[Update article]: External parameters (https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/external-parameters) #4060

Open
@DamianEdwards

Description

@DamianEdwards

Proposed topic or title

Update to existing article

Location in table of contents.

Existing article

Reason for the article

Missing parameter values will now be prompted for when running the dashboard and when running aspire publish.

When running an AppHost, parameters with no default value or no value provided from configuration will cause the dashboard to display a notification bar that says parameters are missing values, with a button that can be clicked to provide values. When the button is clicked, a form will be rendered where values for parameters can be provided.

Image

Each input on the form can be customized when the parameter is created in the AppHost project using the new WithDescription, WithMarkdownDescription, and WithCustomInput methods. The first two methods are pretty self-explanatory. The last method allows you to provide a callback (Func<ParameterResource, InteractionInput>) that can be used to customize the InteractionInput instance used to render the input field for the parameter value. This can be used to customize the default value, input type (e.g. number, choice, text, etc.), label, and placeholder:

var externalServiceUrl = builder.AddParameter("external-service-url")
    .WithDescription("The URL of the external service.")
    .WithCustomInput(p => new()
    {
#pragma warning disable ASPIREINTERACTION001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
        InputType = InputType.Text,
#pragma warning restore ASPIREINTERACTION001
        Value = "https://example.com",
        Label = p.Name,
        Placeholder = $"Enter value for {p.Name}",
        Description = p.Description
    });
var externalService = builder.AddExternalService("external-service", externalServiceUrl);

This will result in an input for the parameter value being rendered like so:

Image

Article abstract

This is updating the existing article to cover details of parameter values being prompted for when they're missing values and how the prompt can be customized for the dashboard.

Relevant searches

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri1High priority, do before Pri2 and Pri3area-docsdoc-ideaIndicates issues that are suggestions for new topics [org][type][category]

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions