Skip to content
DocsTry Aspire
DocsTry

PostgresBuilderExtensions Methods

ClassMethods2 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?)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<PostgresServerResource>The Postgres server resource builder.
configureContainerAction<IResourceBuilder<AdminerContainerResource>>optionalConfiguration callback for Adminer container resource.
containerNamestring?optionalThe 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?)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<PostgresServerResource>The Postgres server resource builder.
configureContainerAction<IResourceBuilder<DbGateContainerResource>>optionalConfiguration callback for DbGate container resource.
containerNamestring?optionalThe 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();