net8.0net9.0net10.0
Aspire hosting extensions for Keycloak (includes PostgreSQL integration).
Published
Mar 5, 2026
7mo ago
Total Downloads
20.9K
20,938
Install
dotnet add package CommunityToolkit.Aspire.Hosting.Keycloak.Extensions --version 13.2.1-beta.528
| Product | Versions |
|---|---|
| .NET |
README
Keycloak Hosting Extensions for Aspire
Overview
This package provides Aspire hosting extensions for integrating Keycloak with your AppHost.
It includes a PostgreSQL integration that works with resources created via Aspire.Hosting.Postgres.AddPostgres() and Aspire.Hosting.Keycloak.AddKeycloak(), and automatically configures the required environment variables for Keycloak database connectivity.
Features
- Configure Keycloak to use PostgreSQL.
- Automatically sets environment variables:
KC_DBKC_DB_URLKC_DB_USERNAMEKC_DB_PASSWORD
- Supports XA transactions via
KC_TRANSACTION_XA_ENABLED. - Integrates with ParameterResource for secure user/password injection.
- Falls back to default credentials (
postgres/postgres) if no parameters are provided. - Fluent extension methods on the hosting model.
Usage (AppHost)
var postgres = builder.AddPostgres("pg");
var db = postgres.AddDatabase("keycloakdb");
// Using explicit username/password parameters
var user = builder.AddParameter("keycloak-user");
var pass = builder.AddParameter("keycloak-pass");
var keycloak = builder.AddKeycloak("kc")
.WithPostgres(db, user, pass);
// Or rely on server parameters or default postgres/postgres
var keycloak2 = builder.AddKeycloak("kc2")
.WithPostgres(db, xaEnabled: true);
Keycloak will be configured with:
KC_DB=postgresKC_DB_URL=jdbc:postgresql://<host>:<port>/keycloakdbKC_DB_USERNAME=<user>KC_DB_PASSWORD=<pass>KC_TRANSACTION_XA_ENABLED=true(when set)
Notes
- Extension methods are in the
Aspire.Hostingnamespace for discoverability in AppHost projects. - If you add custom resource types, place them under
Aspire.Hosting.ApplicationModel.
Changes from Previous Version
No structural changes between v13.1.2-beta.518 and v13.2.1-beta.528.
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.