Share via


PostgresBuilderExtensions.AddPostgres Method

Definition

Adds a PostgreSQL resource to the application model. A container is used for local development. This version the package defaults to the 16.2 tag of the postgres container image

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresServerResource> AddPostgres (this Aspire.Hosting.IDistributedApplicationBuilder builder, string name, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource>? userName = default, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource>? password = default, int? port = default);
static member AddPostgres : Aspire.Hosting.IDistributedApplicationBuilder * string * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> * Nullable<int> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresServerResource>
<Extension()>
Public Function AddPostgres (builder As IDistributedApplicationBuilder, name As String, Optional userName As IResourceBuilder(Of ParameterResource) = Nothing, Optional password As IResourceBuilder(Of ParameterResource) = Nothing, Optional port As Nullable(Of Integer) = Nothing) As IResourceBuilder(Of PostgresServerResource)

Parameters

name
String

The name of the resource. This name will be used as the connection string name when referenced in a dependency.

userName
IResourceBuilder<ParameterResource>

The parameter used to provide the user name for the PostgreSQL resource. If null a default value will be used.

password
IResourceBuilder<ParameterResource>

The parameter used to provide the administrator password for the PostgreSQL resource. If null a random password will be generated.

port
Nullable<Int32>

The host port used when launching the container. If null a random port will be assigned.

Returns

A reference to the IResourceBuilder<T>.

Applies to