-
Notifications
You must be signed in to change notification settings - Fork 475
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
Remove ConnectionString on With methods in Hosting App Model #84
Conversation
Instead, add new Add overloads that take a connection string to an existing server. Fix #62
public static IDistributedApplicationComponentBuilder<SqlServerComponent> AddSqlServer(this IDistributedApplicationBuilder builder, string name, string connectionString) | ||
{ | ||
return builder.AddComponent(new SqlServerComponent(name, connectionString)) | ||
.WithAnnotation(new ManifestPublishingCallbackAnnotation(WriteSqlServerComponentToManifest)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this redis component is being created based on a connection string we need to adjust the manifest writing for components created like this to include a connection string attribute. It should look like this:
{
"components": {
"<name>": {
"type": "redis.v1",
"connectionString": "<connection string>"
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I can make that change. I am a little concerned how the deployment tool is going to decide if this is the real connection string to use, or if it should provision a new one.
I think the main scenario is that the dev wants to use this specific connection string at dev time, but wants something different at publish time.
cc @ellismg - in case you have thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine for this to be ambiguous for now. We have this problem with other environment variables as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So my thinking here is that if the connectionString
property is present on a redis.v1 component, we respect it, when you have another component that does a reference like this:
"env": {
"ConnectionStrings__redis": "{redis.connectionString}"
},
And if connectionString
is not present in this object in the manifest, then we use the value that would be injected by ACA and their connected services stuff?
Does that make sense? Using the existance of this key in the object to distinguish between "a literal" vs "something that needs to be resolved by the underlying platform"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidfowl - maybe this is where the "DevHost" configuration stuff we talked about this week comes in. The DevHost code would have something like:
builder.AddRedis("cache", builder.Configuration.GetConnectionString("redisConnection"));
And then in DevHost\appsettings.Development.json
(or user secrets):
{
"ConnectionStrings": {
"redisConnection": "localhost:6379"
}
}
So when you F5 / dotnet run
locally, you get a connection to localhost:6379
.
Then at "manifest" generation time, you don't define ConnectionStrings:redisConnection
, which means the above will return null
, and that will mean "I want a new resource created for me for this".
This looks good. I'm not sure about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved pending comment around manifest generation.
- Write the connectionString to the manifest if it is provided. - Use DistributedApplicationException
637927d
to
433ed2e
Compare
Instead, add new Add overloads that take a connection string to an existing server.
Note - I needed to make
IDistributedApplicationComponentBuilder<out T>
anout
generic because I needIDistributedApplicationComponentBuilder<PostgresContainerComponent>
to also be anIDistributedApplicationComponentBuilder<IPostgresComponent>
.Fix #62