Keycloak: support external databases via WithReference
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
When using the Keycloak integration, I have to manually configure the SQL Database connection string by setting the `KC_DB_URL` environment variable with a JDBC string that I build myself from my database resource.:
```cs
ctx.EnvironmentVariables.Add("KC_DB_URL", $"jdbc:sqlserver://{sqlServer.Resource.PrimaryEndpoint.ContainerHost};databaseName={keycloakDatabase.Resource.DatabaseName};trustServerCertificate=true;user=sa;password={sqlServer.Resource.PasswordParameter.Value};");
```
This works ok locally, but could be done by Aspire.
When it comes to deploying to Azure using `azd up`, I assume the connection string will need to cater for the AD auth that is setup automatically for me, and so I would need to have a ternary to build the string in a different way based on IsRunMode v IsPublishMode, and things start to get a little messy.
### Describe the solution you'd like
I would like to be able to pass the database using `WithReference(myDb)` like I can do for other projects, and have the connection string automatically configured for use by Keycloak
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.