-
I'm trying to add a MS SQL db to my Aspire project, but I would like to use a permanent password so I can check my db in MSSQL Management Studio (or Azure Data Studio). I've tried to define it like below, but I keep getting a AppHost - Program.cs
Api - Program.cs
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is where you use parameters in the application model. If you look at the overloads of AddSqlServer, you'll see there's a password parameter that takes an var password = builder.AddParameter("sqlPass", secret: true);
var db = builder.AddSqlServer("test-sql-server", port: 54478, password: password)
.AddDatabase("test-db", "test");
var api = builder.AddProject<Projects.Test_Api>("test-api")
.WithReference(db); The value for this parameter should be set in user secrets. Parameters are read from configuration in the format "Parameters:parametername", so the above would be "Parameters:sqlPass". You can learn more about parameters here https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/external-parameters |
Beta Was this translation helpful? Give feedback.
This is where you use parameters in the application model. If you look at the overloads of AddSqlServer, you'll see there's a password parameter that takes an
IResourceBuilder<ParameterResource>
.The value for this parameter should be set in user secrets. Parameters are read from configuration in the format "Parameters:parametername", so the above would be "Parameters:sqlPass".
You can learn more about parameters here https:/…