Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance external parameters article with 9.2 AddConnectionString capabilities #2710

Open
davidfowl opened this issue Mar 3, 2025 · 0 comments
Labels
⌚ Not Triaged Not triaged

Comments

@davidfowl
Copy link
Member

davidfowl commented Mar 3, 2025

We just merged dotnet/aspire#7826 into 9.2 which adds an overload of AddConnectionString that supports passing in a reference expression.

There are a few key things this enables:

  1. Creating adhoc connection strings made from various parameters:

    var openAiKey = builder.AddParameter("openaikey", secret: true);
    var oaiCs = builder.AddConnectionString("llm", ReferenceExpression.Create($"Endpoint=https://api.openai.com/v1;Key={openAiKey}"));
  2. Appending to existing connection strings.

     var builder = DistributedApplication.CreateBuilder(args);
    
     var postgres = builder
         .AddPostgres("postgres")
    
     var database = postgres.AddDatabase("db");
    
     var cs = builder.AddConnectionString("database", ReferenceExpression.Create($"{database};Include Error Details=true"));
    
     var backend = builder
         .AddProject<Projects.Backend>("backend")
         .WithReference(cs)
         .WaitFor(cs);
    
     builder.Build().Run();

    Waiting for a connection string will wait for the database implicitly.

This article should be updated to show the new scenarios.

@dotnetrepoman dotnetrepoman bot added the ⌚ Not Triaged Not triaged label Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⌚ Not Triaged Not triaged
Projects
None yet
Development

No branches or pull requests

1 participant