# AddPostgres

- Module: [Aspire.Hosting.PostgreSQL](/reference/api/go/aspire.hosting.postgresql.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: `DistributedApplicationBuilder`
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Adds a PostgreSQL resource to the application model. A container is used for local development.

## Definition

```go
func (DistributedApplicationBuilder) AddPostgres(
    name string,
    options ...*AddPostgresOptions,
) PostgresServerResource
```

## Parameters

- `name` (`string`) -- The name of the resource. This name will be used as the connection string name when referenced in a dependency.
- `options` (`...*AddPostgresOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*AddPostgresOptions` argument.

- `UserName` (`*ParameterResource`) -- The parameter used to provide the user name for the PostgreSQL resource. If `null` a default value will be used.
- `Password` (`*ParameterResource`) -- The parameter used to provide the administrator password for the PostgreSQL resource. If `null` a random password will be generated.
- `Port` (`*float64`) -- The host port used when launching the container. If null a random port will be assigned.

## Returns

[`PostgresServerResource`](/reference/api/go/aspire.hosting.postgresql/postgresserverresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Applies to

- `DistributedApplicationBuilder`
