You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i'm trying to deploy my Aspire solution to the Azure cloud. I'm having some trouble when configuring Keycloak environment variables to connect to the deployed Azure PostgreSql (also a resource of the same solution).
I made a simple extension method for the KeycloakResource, which accepts the AzurePostgresFlexibleServerDatabaseResource i'm trying to configure:
public static IResourceBuilder<KeycloakResource> WithDatabase(this IResourceBuilder<KeycloakResource> builder, IResourceBuilder<AzurePostgresFlexibleServerDatabaseResource> source)
{
builder.WithEnvironment(async context =>
{
if (context.ExecutionContext.IsPublishMode)
{
context.EnvironmentVariables.Add("TEST_KC_DB", "");
context.EnvironmentVariables.Add("TEST_KC_DB_PASSWORD", "");
context.EnvironmentVariables.Add("TEST_KC_DB_URL", "");
context.EnvironmentVariables.Add("TEST_KC_DB_USERNAME", "");
context.EnvironmentVariables.Add("TEST_KC_HOSTNAME", "");
}
else
{
var dbConnection = await source.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None);
var connStringBuilder = new Npgsql.NpgsqlConnectionStringBuilder(dbConnection);
var keycloakDb = source.Resource;
context.EnvironmentVariables.Add("KC_DB", "postgres");
context.EnvironmentVariables.Add("KC_DB_PASSWORD", connStringBuilder.Password);
context.EnvironmentVariables.Add("KC_DB_URL", $"jdbc:postgresql://pgsql:5432/{keycloakDb.DatabaseName}");
context.EnvironmentVariables.Add("KC_DB_USERNAME", connStringBuilder.Username);
context.EnvironmentVariables.Add("KC_HOSTNAME", connStringBuilder.Host);
}
});
return builder;
}
For local development, i've retrieved successfully the connection string at runtime, and everything runs smoothly, but i'm having trouble doing the same for when the solution gets deployed (using Visual Studio publish profile at this moment).
For reference, here are the configured resources in the AppHost:
Hello,
i'm trying to deploy my Aspire solution to the Azure cloud. I'm having some trouble when configuring Keycloak environment variables to connect to the deployed Azure PostgreSql (also a resource of the same solution).
I made a simple extension method for the KeycloakResource, which accepts the AzurePostgresFlexibleServerDatabaseResource i'm trying to configure:
For local development, i've retrieved successfully the connection string at runtime, and everything runs smoothly, but i'm having trouble doing the same for when the solution gets deployed (using Visual Studio publish profile at this moment).
For reference, here are the configured resources in the AppHost:
KeycloakResource
AzurePostgresFlexibleServerDatabaseResource
Any tips on improving this implementation and how to get the parameters i need when publishing?
Thank you in advance,
Roberto
The text was updated successfully, but these errors were encountered: