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

Add missing port configuration to AddAzurePostgresFlexibleServer RunAsContainer #6276

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static IResourceBuilder<PostgresServerResource> AsAzurePostgresFlexibleSe
/// By default, the Azure PostgreSQL Flexible Server resource is configured to use Microsoft Entra ID (Azure Active Directory) for authentication.
/// This requires changes to the application code to use an azure credential to authenticate with the resource. See
/// https://learn.microsoft.com/azure/postgresql/flexible-server/how-to-connect-with-managed-identity#connect-using-managed-identity-in-c for more information.
///
///
/// You can use the <see cref="WithPasswordAuthentication"/> method to configure the resource to use password authentication.
/// </remarks>
/// <example>
Expand Down
16 changes: 16 additions & 0 deletions src/Aspire.Hosting.PostgreSQL/PostgresBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@ public static IResourceBuilder<T> WithPgAdmin<T>(this IResourceBuilder<T> builde
}
}

/// <summary>
/// Configures the host port that the PostgresServer resource is exposed on instead of using randomly assigned port.
/// </summary>
/// <param name="builder">The resource builder for PostgresServer.</param>
/// <param name="port">The port to bind on the host. If <see langword="null"/> is used random port will be assigned.</param>
/// <returns>The resource builder for PostgresServer.</returns>
public static IResourceBuilder<PostgresServerResource> WithHostPort(this IResourceBuilder<PostgresServerResource> builder, int? port)
{
ArgumentNullException.ThrowIfNull(builder);

return builder.WithEndpoint("http", endpoint =>
{
endpoint.Port = port;
});
}

/// <summary>
/// Configures the host port that the PGAdmin resource is exposed on instead of using randomly assigned port.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/Aspire.Hosting.PostgreSQL/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ Aspire.Hosting.ApplicationModel.PostgresServerResource.UserNameParameter.set ->
Aspire.Hosting.Postgres.PgWebContainerResource
Aspire.Hosting.Postgres.PgWebContainerResource.PgWebContainerResource(string! name) -> void
Aspire.Hosting.Postgres.PgWebContainerResource.PrimaryEndpoint.get -> Aspire.Hosting.ApplicationModel.EndpointReference!
static Aspire.Hosting.PostgresBuilderExtensions.WithHostPort(this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresServerResource!>! builder, int? port) -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresServerResource!>!
static Aspire.Hosting.PostgresBuilderExtensions.WithHostPort(this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Postgres.PgWebContainerResource!>! builder, int? port) -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Postgres.PgWebContainerResource!>!
static Aspire.Hosting.PostgresBuilderExtensions.WithPgWeb(this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresServerResource!>! builder, System.Action<Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Postgres.PgWebContainerResource!>!>? configureContainer = null, string? containerName = null) -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresServerResource!>!