Skip to content
Docs Try Aspire
Docs Try

PostgresBuilderExtensions Methods

Class Methods 2 members
Provides extension methods for adding PostgreSQL resources to an Hosting.IDistributedApplicationBuilder.
WithAdminer(IResourceBuilder<PostgresServerResource>, Action<IResourceBuilder<AdminerContainerResource>>, string?) Section titled WithAdminer(IResourceBuilder<PostgresServerResource>, Action<IResourceBuilder<AdminerContainerResource>>, string?) extension IResourceBuilder<PostgresServerResource>
Adds an administration and development platform for PostgreSQL to the application model using Adminer.
public static class PostgresBuilderExtensions
{
public static IResourceBuilder<PostgresServerResource> WithAdminer(
this IResourceBuilder<PostgresServerResource> builder,
Action<IResourceBuilder<AdminerContainerResource>>? configureContainer = null,
string? containerName = null)
{
// ...
}
}
builder IResourceBuilder<PostgresServerResource> The Postgres server resource builder.
configureContainer Action<IResourceBuilder<AdminerContainerResource>> optional Configuration callback for Adminer container resource.
containerName string? optional The name of the container (Optional).
IResourceBuilder<PostgresServerResource> A reference to the ApplicationModel.IResourceBuilder`1.
This version of the package defaults to the tag of the container image.

This overload is not available in polyglot app hosts. Use the overload without the configuration callback instead.

Use in application host with a Postgres resource

var builder = DistributedApplication.CreateBuilder(args);
var postgres = builder.AddPostgres("postgres")
.WithAdminer();
var db = postgres.AddDatabase("db");
var api = builder.AddProject<Projects.Api>("api")
.WithReference(db);
builder.Build().Run();
WithDbGate(IResourceBuilder<PostgresServerResource>, Action<IResourceBuilder<DbGateContainerResource>>, string?) Section titled WithDbGate(IResourceBuilder<PostgresServerResource>, Action<IResourceBuilder<DbGateContainerResource>>, string?) extension IResourceBuilder<PostgresServerResource>
Adds an administration and development platform for PostgreSQL to the application model using DbGate.
public static class PostgresBuilderExtensions
{
public static IResourceBuilder<PostgresServerResource> WithDbGate(
this IResourceBuilder<PostgresServerResource> builder,
Action<IResourceBuilder<DbGateContainerResource>>? configureContainer = null,
string? containerName = null)
{
// ...
}
}
builder IResourceBuilder<PostgresServerResource> The Postgres server resource builder.
configureContainer Action<IResourceBuilder<DbGateContainerResource>> optional Configuration callback for DbGate container resource.
containerName string? optional The name of the container (Optional).
IResourceBuilder<PostgresServerResource> A reference to the ApplicationModel.IResourceBuilder`1.
This version of the package defaults to the tag of the container image.

This overload is not available in polyglot app hosts. Use the overload without the configuration callback instead.

Use in application host with a Postgres resource

var builder = DistributedApplication.CreateBuilder(args);
var postgres = builder.AddPostgres("postgres")
.WithDbGate();
var db = postgres.AddDatabase("db");
var api = builder.AddProject<Projects.Api>("api")
.WithReference(db);
builder.Build().Run();