The best way to merge the configuration from a json file and an existing Keycloak database

Hi everyone.

I have two Keycloak servers that I configured using the json file with the original configuration.

After that, the “clients” on the servers added new addresses to validRedrectUrls (in other words changed the configuration a bit).

I added the new client to the json file with the original configuration.
Now I’m going to update the Keycloak servers and apply the configuration from json file with new clien(ideally do it automatically). But if I overwrite the server configuration, I will lose all the “client’s” changes on the servers.

Can you give advice on how to solve this problem?

You should keep the json your source of truth.

Don’t do any configuration change in keycloak interface. Do your initial configuration, export the realm (with clients) and do any change for that moment on in the json (or change in the interface then export again).

Put the file in a location available to keycloak and use KEYCLOAK_IMPORT environment variable pointing to the file.

Every time keycloak restarts, it re-read the json file.