# PostgresServerResource

- Kind: `class`
- Package: [Aspire.Hosting.PostgreSQL](/reference/api/csharp/aspire.hosting.postgresql.md)
- Version: `13.4.0`
- Namespace: `Aspire.Hosting.ApplicationModel`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.PostgreSQL/PostgresServerResource.cs)
- Inherits: `ContainerResource`
- Implements: `IExpressionValue`, `IManifestExpressionProvider`, `IResource`, `IResourceWithConnectionString`, `IValueProvider`, `IValueWithReferences`

A resource that represents a PostgreSQL container.

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public class PostgresServerResource
    : Aspire.Hosting.ApplicationModel.ContainerResource,
      Aspire.Hosting.ApplicationModel.IExpressionValue,
      Aspire.Hosting.ApplicationModel.IManifestExpressionProvider,
      Aspire.Hosting.ApplicationModel.IResource,
      Aspire.Hosting.ApplicationModel.IResourceWithConnectionString,
      Aspire.Hosting.ApplicationModel.IValueProvider,
      Aspire.Hosting.ApplicationModel.IValueWithReferences
{
    // ...
}
```

## ATS metadata

### ATS export

- Type ID: `Aspire.Hosting.PostgreSQL/PostgresServerResource`

## Constructors

- [PostgresServerResource(string, ParameterResource?, ParameterResource)](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/constructors.md#constructor-string-parameterresource-parameterresource) -- Initializes a new instance of the [PostgresServerResource](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource.md) class.

## Properties

- [ConnectionStringExpression](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/properties.md#connectionstringexpression) : `ReferenceExpression` `get` -- Gets the connection string expression for the PostgreSQL server.
- [Databases](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/properties.md#databases) : `IReadOnlyDictionary<string, string>` `get` -- A dictionary where the key is the resource name and the value is the database name.
- [Host](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/properties.md#host) : `EndpointReferenceExpression` `get` -- Gets the host endpoint reference for this service.
- [JdbcConnectionString](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/properties.md#jdbcconnectionstring) : `ReferenceExpression` `get` -- Gets the JDBC connection string for the PostgreSQL server.
- [PasswordParameter](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/properties.md#passwordparameter) : `ParameterResource` `get; set` -- Gets or sets the parameter that contains the PostgreSQL server password.
- [Port](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/properties.md#port) : `EndpointReferenceExpression` `get` -- Gets the endpoint reference expression that identifies the port for this endpoint.
- [PrimaryEndpoint](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/properties.md#primaryendpoint) : `EndpointReference` `get` -- Gets the primary endpoint for the PostgreSQL server.
- [UriExpression](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/properties.md#uriexpression) : `ReferenceExpression` `get` -- Gets the connection URI expression for the PostgreSQL server.
- [UserNameParameter](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/properties.md#usernameparameter) : `ParameterResource?` `get; set` -- Gets or sets the parameter that contains the PostgreSQL server user name.
- [UserNameReference](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/properties.md#usernamereference) : `ReferenceExpression` `get` -- Gets a reference to the user name for the PostgreSQL server.

## Methods

- [GetConnectionStringAsync(CancellationToken)](/reference/api/csharp/aspire.hosting.postgresql/postgresserverresource/methods.md#getconnectionstringasync-cancellationtoken) : `ValueTask<string?>` -- Gets the connection string for the PostgreSQL server.
