# AzurePostgresExtensions

- Kind: `class`
- Package: [Aspire.Hosting.Azure.PostgreSQL](/reference/api/csharp/aspire.hosting.azure.postgresql.md)
- Version: `13.3.0`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresExtensions.cs)

Provides extension methods for adding the Azure PostgreSQL resources to the application model.

## Definition

```csharp
namespace Aspire.Hosting;

public static class AzurePostgresExtensions
{
    // ...
}
```

## Methods

- [AddAzurePostgresFlexibleServer(IDistributedApplicationBuilder, string)](/reference/api/csharp/aspire.hosting.azure.postgresql/azurepostgresextensions/methods.md#addazurepostgresflexibleserver-idistributedapplicationbuilder-string) : `IResourceBuilder<AzurePostgresFlexibleServerResource>` `extension` `ats export` -- Adds an Azure PostgreSQL Flexible Server resource to the application model.
- [AddDatabase(IResourceBuilder<AzurePostgresFlexibleServerResource>, string, string?)](/reference/api/csharp/aspire.hosting.azure.postgresql/azurepostgresextensions/methods.md#adddatabase-iresourcebuilder-azurepostgresflexibleserverresource-string-string) : `IResourceBuilder<AzurePostgresFlexibleServerDatabaseResource>` `extension` `ats export` -- Adds an Azure PostgreSQL database to the application model.
- [AsAzurePostgresFlexibleServer(IResourceBuilder<PostgresServerResource>)](/reference/api/csharp/aspire.hosting.azure.postgresql/azurepostgresextensions/methods.md#asazurepostgresflexibleserver-iresourcebuilder-postgresserverresource) : `IResourceBuilder<PostgresServerResource>` `extension` `obsolete` -- Configures resource to use Azure for local development and when doing a deployment via the Azure Developer CLI.
- [PublishAsAzurePostgresFlexibleServer(IResourceBuilder<PostgresServerResource>)](/reference/api/csharp/aspire.hosting.azure.postgresql/azurepostgresextensions/methods.md#publishasazurepostgresflexibleserver-iresourcebuilder-postgresserverresource) : `IResourceBuilder<PostgresServerResource>` `extension` `obsolete` -- Configures Postgres Server resource to be deployed as Azure PostgreSQL Flexible Server.
- [RunAsContainer(IResourceBuilder<AzurePostgresFlexibleServerResource>, Action<IResourceBuilder<PostgresServerResource>>)](/reference/api/csharp/aspire.hosting.azure.postgresql/azurepostgresextensions/methods.md#runascontainer-iresourcebuilder-azurepostgresflexibleserverresource-action-iresourcebuilder-postgresserverresource) : `IResourceBuilder<AzurePostgresFlexibleServerResource>` `extension` `ats export` -- Configures an Azure PostgreSQL Flexible Server resource to run locally in a container.
- [WithPasswordAuthentication(IResourceBuilder<AzurePostgresFlexibleServerResource>, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)](/reference/api/csharp/aspire.hosting.azure.postgresql/azurepostgresextensions/methods.md#withpasswordauthentication-iresourcebuilder-azurepostgresflexibleserverresource-iresourcebuilder-parameterresource-iresourcebuilder-parameterresource) : `IResourceBuilder<AzurePostgresFlexibleServerResource>` `extension` `ats ignored` -- Configures the resource to use password authentication for Azure PostgreSQL Flexible Server.
- [WithPasswordAuthentication(IResourceBuilder<AzurePostgresFlexibleServerResource>, IResourceBuilder<IAzureKeyVaultResource>, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)](/reference/api/csharp/aspire.hosting.azure.postgresql/azurepostgresextensions/methods.md#withpasswordauthentication-iresourcebuilder-azurepostgresflexibleserverresource-iresourcebuilder-iazurekeyvaultresource-iresourcebuilder-parameterresource-iresourcebuilder-parameterresource) : `IResourceBuilder<AzurePostgresFlexibleServerResource>` `extension` `ats ignored` -- Configures the resource to use password authentication for Azure PostgreSQL Flexible Server. This overload is used when the PostgreSQL resource is created in a container and the password is stored in an Azure Key Vault secret.
- [WithPostgresMcp(IResourceBuilder<AzurePostgresFlexibleServerDatabaseResource>, Action<IResourceBuilder<PostgresMcpContainerResource>>, string?)](/reference/api/csharp/aspire.hosting.azure.postgresql/azurepostgresextensions/methods.md#withpostgresmcp-iresourcebuilder-azurepostgresflexibleserverdatabaseresource-action-iresourcebuilder-postgresmcpcontainerresource-string) : `IResourceBuilder<AzurePostgresFlexibleServerDatabaseResource>` `extension` `experimental` `ats export` -- Adds a Postgres MCP server container and configures it to connect to the database represented by `builder`.
