-
Notifications
You must be signed in to change notification settings - Fork 543
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
Provide optional arguments for password/port when running as a container #6886
base: main
Are you sure you want to change the base?
Provide optional arguments for password/port when running as a container #6886
Conversation
@eerhardt we should do this in 9.1 |
@@ -146,7 +148,7 @@ public static IResourceBuilder<AzureSqlDatabaseResource> AddDatabase(this IResou | |||
/// builder.Build().Run(); | |||
/// </code> | |||
/// </example> | |||
public static IResourceBuilder<AzureSqlServerResource> RunAsContainer(this IResourceBuilder<AzureSqlServerResource> builder, Action<IResourceBuilder<SqlServerServerResource>>? configureContainer = null) | |||
public static IResourceBuilder<AzureSqlServerResource> RunAsContainer(this IResourceBuilder<AzureSqlServerResource> builder, Action<IResourceBuilder<SqlServerServerResource>>? configureContainer = null, IResourceBuilder<ParameterResource>? password = null, int? port = null) |
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 @sebastienros @ReubenBond @JamesNK @DamianEdwards - are we concerned with binary breaking changes like this in the Hosting integrations? Part of me thinks this is OK, but wanted to check what everyone else thinks.
If we didn't go with this approach, we could take one of 2 approaches:
- Just add 1 new overload that took all parameters, and callers would pass in
null
explicitly for the parameters they aren't supplying. - Explode the API out with 8 overloads - every combination of parameters - which feels excessive.
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.
An alternative is to expose some methods that allow for configuring the port and the password during the configureContainer
callback.
See 15e8a26 for an example:
var sql1 = builder.AddAzureSqlServer("sql1")
.RunAsContainer(c =>
{
c.WithHostPort(5555);
});
The downside with just exposing it on these 3 containers is that it isn't consistent with the rest of the "top level" containers - like MongoDB, RabbitMQ, etc. If we go with this route, would we add it to all of them 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.
I think we've generally been fine with adding new optional parameters to existing methods right?
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.
We haven't been fine in the client integration libraries, since it is a binary breaking change. But I'm not sure we care as much in the hosting integrations libraries.
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.
Yeah I guess I'm basing this on what we've done in ASP.NET Core itself and Aspire.Hosting
, or I'm totally misremembering 😄
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.
Don't make binary breaking changes in minors. Just add overloads 😄
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 I'm in favor of taking the alternative approach above:
var sql1 = builder.AddAzureSqlServer("sql1")
.RunAsContainer(c =>
{
c.WithHostPort(5555);
});
This fits with our other "emulator" containers, and allows us to not have an explosion of overloads.
We would also then have a .WithPassword(IResourceBuilder<ParameterResource>)
extension as well that allows you to set the password after the constructor.
Opinions on taking this approach?
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 thought about that as well but it would require more changes to the way that the underlying SqlServerResource is created/updated.
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 agree it would require some more changes throughout, but I think it provides a better API experience.
Description
Adds optional parameters from the underlying call to
AddSqlServer
for the password and the port. This allows users to specify these properties when using Azure Sql to run locally as a container for development and still optionally configure the password/port like you can when using the SqlServerAddSqlServer
method directly.This can be helpful for local development as the port will shift each time the AppHost is run.
Fixes # (issue)
Checklist
<remarks />
and<code />
elements on your triple slash comments?breaking-change
template):doc-idea
template):Microsoft Reviewers: Open in CodeFlow