# PostgresServerResource

- Module: [Aspire.Hosting.Azure.PostgreSQL](/reference/api/typescript/aspire.hosting.azure.postgresql.md)
- Version: `13.2.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

## Definition

```typescript
interface PostgresServerResource
  extends IComputeResource,
    IManifestExpressionProvider,
    IResource,
    IResourceWithArgs,
    IResourceWithConnectionString,
    IResourceWithEndpoints,
    IResourceWithEnvironment,
    IResourceWithProbes,
    IResourceWithWaitSupport,
    IValueProvider,
    IValueWithReferences {
  readonly connectionStringExpression: ReferenceExpression;
  readonly databases: Dict<string,string>;
  entrypoint: string;
  readonly host: EndpointReferenceExpression;
  readonly jdbcConnectionString: ReferenceExpression;
  readonly name: string;
  passwordParameter: ParameterResource;
  readonly port: EndpointReferenceExpression;
  readonly primaryEndpoint: EndpointReference;
  shellExecution: boolean;
  readonly uriExpression: ReferenceExpression;
  userNameParameter: ParameterResource;
  readonly userNameReference: ReferenceExpression;
  addDatabase(
      name: string,
      databaseName?: string): PostgresDatabaseResource;
  withDataBindMount(
      source: string,
      isReadOnly?: boolean): PostgresServerResource;
  withDataVolume(
      name?: string,
      isReadOnly?: boolean): PostgresServerResource;
  withHostPort(port: number): PostgresServerResource;
  withInitFiles(source: string): PostgresServerResource;
  withPassword(password: ParameterResource): PostgresServerResource;
  withPgAdmin(configureContainer?: (obj: PgAdminContainerResource) => Promise<void>, containerName?: string): PostgresServerResource;
  withPgWeb(configureContainer?: (obj: PgWebContainerResource) => Promise<void>, containerName?: string): PostgresServerResource;
  withUserName(userName: ParameterResource): PostgresServerResource;
}
```

## Properties

- `connectionStringExpression`: `ReferenceExpression` `get` -- Gets the ConnectionStringExpression property
- `databases`: `Dict<string,string>` `get` -- Gets the Databases property
- `entrypoint`: `string` `get - set` -- Gets the Entrypoint property
- `host`: `EndpointReferenceExpression` `get` -- Gets the Host property
- `jdbcConnectionString`: `ReferenceExpression` `get` -- Gets the JdbcConnectionString property
- `name`: `string` `get` -- Gets the Name property
- `passwordParameter`: `ParameterResource` `get - set` -- Gets the PasswordParameter property
- `port`: `EndpointReferenceExpression` `get` -- Gets the Port property
- `primaryEndpoint`: `EndpointReference` `get` -- Gets the PrimaryEndpoint property
- `shellExecution`: `boolean` `get - set` -- Gets the ShellExecution property
- `uriExpression`: `ReferenceExpression` `get` -- Gets the UriExpression property
- `userNameParameter`: `ParameterResource` `get - set` -- Gets the UserNameParameter property
- `userNameReference`: `ReferenceExpression` `get` -- Gets the UserNameReference property

## Methods

- [addDatabase](/reference/api/typescript/aspire.hosting.azure.postgresql/postgresserverresource/adddatabase.md) -- `method` -- Adds a PostgreSQL database
    ```typescript
  addDatabase(name: string, databaseName?: string): PostgresDatabaseResource
  ```
- [withDataBindMount](/reference/api/typescript/aspire.hosting.azure.postgresql/postgresserverresource/withdatabindmount.md) -- `method` -- Adds a data bind mount for PostgreSQL
    ```typescript
  withDataBindMount(source: string, isReadOnly?: boolean): PostgresServerResource
  ```
- [withDataVolume](/reference/api/typescript/aspire.hosting.azure.postgresql/postgresserverresource/withdatavolume.md) -- `method` -- Adds a data volume for PostgreSQL
    ```typescript
  withDataVolume(name?: string, isReadOnly?: boolean): PostgresServerResource
  ```
- [withHostPort](/reference/api/typescript/aspire.hosting.azure.postgresql/postgresserverresource/withhostport.md) -- `method` -- Sets the host port for PostgreSQL
    ```typescript
  withHostPort(port: number): PostgresServerResource
  ```
- [withInitFiles](/reference/api/typescript/aspire.hosting.azure.postgresql/postgresserverresource/withinitfiles.md) -- `method` -- Copies init files to PostgreSQL
    ```typescript
  withInitFiles(source: string): PostgresServerResource
  ```
- [withPassword](/reference/api/typescript/aspire.hosting.azure.postgresql/postgresserverresource/withpassword.md) -- `method` -- Configures the PostgreSQL password
    ```typescript
  withPassword(password: ParameterResource): PostgresServerResource
  ```
- [withPgAdmin](/reference/api/typescript/aspire.hosting.azure.postgresql/postgresserverresource/withpgadmin.md) -- `method` -- Adds pgAdmin 4 management UI
    ```typescript
  withPgAdmin(configureContainer?: (obj: PgAdminContainerResource) => Promise<void>, containerName?: string): PostgresServerResource
  ```
- [withPgWeb](/reference/api/typescript/aspire.hosting.azure.postgresql/postgresserverresource/withpgweb.md) -- `method` -- Adds pgweb management UI
    ```typescript
  withPgWeb(configureContainer?: (obj: PgWebContainerResource) => Promise<void>, containerName?: string): PostgresServerResource
  ```
- [withUserName](/reference/api/typescript/aspire.hosting.azure.postgresql/postgresserverresource/withusername.md) -- `method` -- Configures the PostgreSQL user name
    ```typescript
  withUserName(userName: ParameterResource): PostgresServerResource
  ```
