Skip to content
Docs Try Aspire

KeycloakResourceBuilderExtensions Methods

Class Methods 9 members
Provides extension methods for adding Keycloak resources to an Hosting.IDistributedApplicationBuilder.
AddKeycloak(IDistributedApplicationBuilder, string, int?, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>) Section titled AddKeycloak(IDistributedApplicationBuilder, string, int?, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>) extension IResourceBuilder<KeycloakResource>
Adds a Keycloak container to the application model.
public static class KeycloakResourceBuilderExtensions
{
public static IResourceBuilder<KeycloakResource> AddKeycloak(
this IDistributedApplicationBuilder builder,
string name,
int? port = null,
IResourceBuilder<ParameterResource>? adminUsername = null,
IResourceBuilder<ParameterResource>? adminPassword = null)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder.
name string The name of the resource.
port int? optional The host port that the underlying container is bound to when running locally.
adminUsername IResourceBuilder<ParameterResource> optional The parameter used as the admin for the Keycloak resource. If null a default value will be used.
adminPassword IResourceBuilder<ParameterResource> optional The parameter used as the admin password for the Keycloak resource. If null a default password will be used.
IResourceBuilder<KeycloakResource> A reference to the ApplicationModel.IResourceBuilder`1.
The container exposes port 8080 by default. This version of the package defaults to the tag of the / container image. Use in application host
var keycloak = builder.AddKeycloak("keycloak");
var myService = builder.AddProject<Projects.MyService<()
.WithReference(keycloak);
WithDataBindMount(IResourceBuilder<KeycloakResource>, string) Section titled WithDataBindMount(IResourceBuilder<KeycloakResource>, string) extension IResourceBuilder<KeycloakResource>
Adds a bind mount for the data folder to a Keycloak container resource.
public static class KeycloakResourceBuilderExtensions
{
public static IResourceBuilder<KeycloakResource> WithDataBindMount(
this IResourceBuilder<KeycloakResource> builder,
string source)
{
// ...
}
}
builder IResourceBuilder<KeycloakResource> The resource builder.
source string The source directory on the host to mount into the container.
IResourceBuilder<KeycloakResource> The ApplicationModel.IResourceBuilder`1.
The source directory is mounted at /opt/keycloak/data in the container. Use a bind mount
var keycloak = builder.AddKeycloak("keycloak")
.WithDataBindMount("mydata");
WithDataVolume(IResourceBuilder<KeycloakResource>, string?) Section titled WithDataVolume(IResourceBuilder<KeycloakResource>, string?) extension IResourceBuilder<KeycloakResource>
Adds a named volume for the data folder to a Keycloak container resource.
public static class KeycloakResourceBuilderExtensions
{
public static IResourceBuilder<KeycloakResource> WithDataVolume(
this IResourceBuilder<KeycloakResource> builder,
string? name = null)
{
// ...
}
}
builder IResourceBuilder<KeycloakResource> The resource builder.
name string? optional The name of the volume. Defaults to an auto-generated name based on the application and resource names.
IResourceBuilder<KeycloakResource> The ApplicationModel.IResourceBuilder`1.
The volume is mounted at /opt/keycloak/data in the container. Use a data volume
var keycloak = builder.AddKeycloak("keycloak")
.WithDataVolume();
WithDisabledFeatures(IResourceBuilder<KeycloakResource>, string[]) Section titled WithDisabledFeatures(IResourceBuilder<KeycloakResource>, string[]) extension IResourceBuilder<KeycloakResource>
Additional feature names to disable for the keycloak resource
public static class KeycloakResourceBuilderExtensions
{
public static IResourceBuilder<KeycloakResource> WithDisabledFeatures(
this IResourceBuilder<KeycloakResource> builder,
params string[] features)
{
// ...
}
}
builder IResourceBuilder<KeycloakResource> The resource builder.
features string[] Names of features to disable for the keycloak resource
IResourceBuilder<KeycloakResource> The ApplicationModel.IResourceBuilder`1.
WithEnabledFeatures(IResourceBuilder<KeycloakResource>, string[]) Section titled WithEnabledFeatures(IResourceBuilder<KeycloakResource>, string[]) extension IResourceBuilder<KeycloakResource>
Additional feature names to enable for the keycloak resource
public static class KeycloakResourceBuilderExtensions
{
public static IResourceBuilder<KeycloakResource> WithEnabledFeatures(
this IResourceBuilder<KeycloakResource> builder,
params string[] features)
{
// ...
}
}
builder IResourceBuilder<KeycloakResource> The resource builder.
features string[] Names of features to enable for the keycloak resource
IResourceBuilder<KeycloakResource> The ApplicationModel.IResourceBuilder`1.
WithOtlpExporter(IResourceBuilder<KeycloakResource>) Section titled WithOtlpExporter(IResourceBuilder<KeycloakResource>) extension IResourceBuilder<KeycloakResource>
Injects the appropriate environment variables to allow the resource to enable sending telemetry to the dashboard.
  1. It ensures the "opentelemetry" Keycloak feature is enabled
  2. It sets the OTLP endpoint to the value of the ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL environment variable.
  3. It sets the service name and instance id to the resource name and UID. Values are injected by the orchestrator.
  4. It sets a small batch schedule delay in development. This reduces the delay that OTLP exporter waits to sends telemetry and makes the dashboard telemetry pages responsive.
public static class KeycloakResourceBuilderExtensions
{
public static IResourceBuilder<KeycloakResource> WithOtlpExporter(
this IResourceBuilder<KeycloakResource> builder)
{
// ...
}
}
builder IResourceBuilder<KeycloakResource> The keycloak resource builder.
IResourceBuilder<KeycloakResource> The ApplicationModel.IResourceBuilder`1.
WithOtlpExporter(IResourceBuilder<KeycloakResource>, OtlpProtocol) Section titled WithOtlpExporter(IResourceBuilder<KeycloakResource>, OtlpProtocol) extension IResourceBuilder<KeycloakResource>
Injects the appropriate environment variables to allow the resource to enable sending telemetry to the dashboard.
  1. It ensures the "opentelemetry" Keycloak feature is enabled
  2. It sets the OTLP endpoint to the value of the ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL environment variable.
  3. It sets the service name and instance id to the resource name and UID. Values are injected by the orchestrator.
  4. It sets a small batch schedule delay in development. This reduces the delay that OTLP exporter waits to sends telemetry and makes the dashboard telemetry pages responsive.
public static class KeycloakResourceBuilderExtensions
{
public static IResourceBuilder<KeycloakResource> WithOtlpExporter(
this IResourceBuilder<KeycloakResource> builder,
OtlpProtocol protocol)
{
// ...
}
}
builder IResourceBuilder<KeycloakResource> The keycloak resource builder.
protocol OtlpProtocol The protocol to use for the OTLP exporter. If not set, it will try gRPC then Http.
IResourceBuilder<KeycloakResource> The ApplicationModel.IResourceBuilder`1.
WithRealmImport(IResourceBuilder<KeycloakResource>, string, bool) Section titled WithRealmImport(IResourceBuilder<KeycloakResource>, string, bool) extension IResourceBuilder<KeycloakResource>
Adds a realm import to a Keycloak container resource.
public static class KeycloakResourceBuilderExtensions
{
public static IResourceBuilder<KeycloakResource> WithRealmImport(
this IResourceBuilder<KeycloakResource> builder,
string import,
bool isReadOnly)
{
// ...
}
}
builder IResourceBuilder<KeycloakResource> The resource builder.
import string The directory containing the realm import files or a single import file.
isReadOnly bool A flag that indicates if the realm import directory is read-only.
IResourceBuilder<KeycloakResource> The ApplicationModel.IResourceBuilder`1.
The realm import files are copied to /opt/keycloak/data/import in the container. Import the realms from a directory
var keycloak = builder.AddKeycloak("keycloak")
.WithRealmImport("../realms");
WithRealmImport(IResourceBuilder<KeycloakResource>, string) Section titled WithRealmImport(IResourceBuilder<KeycloakResource>, string) extension IResourceBuilder<KeycloakResource>
Adds a realm import to a Keycloak container resource.
public static class KeycloakResourceBuilderExtensions
{
public static IResourceBuilder<KeycloakResource> WithRealmImport(
this IResourceBuilder<KeycloakResource> builder,
string import)
{
// ...
}
}
builder IResourceBuilder<KeycloakResource> The resource builder.
import string The directory containing the realm import files or a single import file.
IResourceBuilder<KeycloakResource> The ApplicationModel.IResourceBuilder`1.
The realm import files are copied to /opt/keycloak/data/import in the container. Import the realms from a directory
var keycloak = builder.AddKeycloak("keycloak")
.WithRealmImport("../realms");