Skip to content

Remove ConnectionStrings prefix for custom resource #7292

Answered by davidfowl
atlass-dev asked this question in Q&A
Discussion options

You must be logged in to vote

Don't use IResourceWithConnectionString. You would write a custom overload like this:

public static IResourceBuilder<TDestination> WithReference<TDestination>(this IResourceBuilder<TDestination> builder, IResourceBuilder<SmtpServer> source)
    where TDestination : IResourceWithEnvironment
{
    return builder.WithEnvironment(context =>
    {
        // Set environment variables here
        context.EnvironmentVariables["Smtp__Host"] = source.Endpoint.Property(EnpointProperty.Host);
        context.EnvironmentVariables["Smtp__Port"] = source.Endpoint.Property(EnpointProperty.Port);
    });
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@atlass-dev
Comment options

@davidfowl
Comment options

Answer selected by atlass-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants