Configuring Java Services

Configuring Java services in the Link platform

Spring Boot uses two main YAML configuration files:

  • bootstrap.yml
    • Loaded before application.yml during the startup process.
    • Used for early-stage configuration that is required before the main application context is loaded.
  • application.yml
    • Loaded after bootstrap.yml, within the main application context.

Some properties may want to be put in environment-specific configuration files with the naming convention bootstrap-ENV.yml and application-ENV.yml. For example, there may be bootstrap-dev.yml and bootstrap-prod.yml. At deployment-time, you can specify an environment variable SPRING_PROFILES_ACTIVE to indicate whether to load dev or prod on top of the default configurations.

To convert a property name in the canonical-form to an environment variable name you can follow these rules:

  • Replace dots (.) with underscores (_).
  • Remove any dashes (-).
  • Convert to uppercase.

For example, the configuration property spring.main.log-startup-info would be an environment variable named SPRING_MAIN_LOGSTARTUPINFO.

Environment variables can also be used when binding to object lists. To bind to a List, the element number should be surrounded with underscores in the variable name.

For example, the configuration property my.service[0].other would use an environment variable named MY_SERVICE_0_OTHER.

Examples of environment variable naming conventions:

YAML / JSON KeyConverted Environment Variable
server.portSERVER_PORT
spring.datasource.urlSPRING_DATASOURCE_URL
spring.cloud.azure.appconfiguration.stores[0].selects[0].label-filterSPRING_CLOUD_AZURE_APPCONFIGURATION_STORES_0_SELECTS_0_LABELFILTER
my.custom.settings[2].api-keyMY_CUSTOM_SETTINGS_2_APIKEY
config.services[1].endpoints.internal-urlCONFIG_SERVICES_1_ENDPOINTS_INTERNALURL

Note: Official guidance is to remove dashes (-) entirely from the environment variable. For example: label-filter becomes LABELFILTER. However, both LABEL-FILTER and LABELFILTER work interchangeably.

Overriding Default Configs

Any of the properties for serivce configuration can be provided either via environment variables, through a custom application.yml file, or via properties set in java using -D<propertyName>=<value> passed as an argument to the JVM during startup.

Azure App Config and Key Vault

Default key-filter and label-filter properties are specified for each service, so that at deployment time only the connection to the Azure App Config or Key Vault services needs to be configured/specified in environment variables.

Property NameDescriptionType/Value
spring.cloud.azure.appconfiguration.enabledEnable Azure App Configurationtrue or false
spring.cloud.azure.appconfiguration.stores[0].connection-stringConnection string to Azure App Config instance (if not using managed identity).<string>
spring.cloud.azure.appconfiguration.stores[0].endpointEndpoint to use for App Config when managed identity should be specified via AZURE_CLIENT_ID<string>
spring.cloud.azure.appconfiguration.stores[0].selects[0].label-filterLabel to use for configuration”,Validation”
spring.cloud.azure.appconfiguration.stores[0].selects[0].key-filterKey to use for configuration”/“

Authentication

Java Azure libraries have difficult using different authentication mechanisms between App Config (AAC) and Key Vault (AKV). If you specify AZURE_CLIENT_ID, it will attempt to use managed identity for both AAC and AKV.

If using managed identity authentication for one, it is suggested to use managed identity for both; not a connectionString with a token/secret embedded in it for AAC and MI for AKV.

Specifying all three AZURE_CLIENT_ID, AZURE_CLIENT_SECRET and AZURE_TENANT_ID is only necessary when using a service principal for authentication. Only AZURE_CLIENT_ID is necessary to authenticate using managed identity.

If using a service principal for authentication, the AZURE_TENANT_ID is not the same as the subscription ID.

Blob Storage

Property NameDescriptionRequiredDefault ValueSecret?
internal-blob-storage.connection-stringConnection string for internal ABSYes (if using ABS)NoneYes
internal-blob-storage.blob-container-nameBlob container name for internal ABSYes (if using ABS)NoneNo

Telemetry

Property NameDescriptionType/Value
telemetry.exporterEndpointEndpoint that can be connected to by scrapers for metric datahttp://localhost:55690
loki.enabledEnable Loki for loggingtrue or false
loki.urlURL for Lokihttp://localhost:3100
loki.appApplication name for Loki”link-dev”

Swagger

Property NameDescriptionType/Value
springdocConfiguration for Swagger and Swagger UISee Springdoc documentation for details
springdoc.api-docs.enabledEnable Swagger specification generationtrue or false (default)
springdoc.swagger-ui.enabledEnable Swagger UItrue or false (default)

Databases

Mongo DB

Property NameDescriptionType/ValueSecret?
spring.data.mongodb.hostHost address for the Mongo database”localhost”No
spring.data.mongodb.portPort for the Mongo database27017No
spring.data.mongodb.databaseDatabase name for the Mongo database”measureeval”No
spring.data.mongodb.usernameUsername for the Mongo database<string>No
spring.data.mongodb.passwordPassword for the Mongo database<string>Yes

SQL Server

Property NameDescriptionType/ValueSecret?
spring.datasource.urlURL for the SQL Server database<string> prefixed with “jdbc:sqlserver://“No
spring.datasource.usernameUsername for the SQL Server database<string>No
spring.datasource.passwordPassword for the SQL Server database<string>Yes
spring.jpa.hibernate.ddl-autoDDL auto setting for JPA/Hibernate”none” (default) or “update”No
spring.jpa.properties.show_sqlShow SQL statements in logstrue (default) or falseNo
spring.jpa.properties.dialectSQL dialect for the database”org.hibernate.dialect.SQLServerDialect” (default)No

Auto Update/Migrate DBs

Property NameDescriptionType/ValueSecret?
spring.jpa.hibernate.ddl-autoIndicates whether how to update the schema in hibernate databasescreate | create-drop | update | validate | noneNo

Kafka

Property NameDescriptionType/ValueSecret?
spring.kafka.bootstrap-serversKafka bootstrap servers”localhost:9092”No
spring.kafka.consumer.group-idKafka consumer group ID”measureeval”No
spring.kafka.producer.client-idKafka producer client ID”measureeval”No
spring.kafka.retry.maxAttemptsMaximum number of times consumption of an event should be retried3No
spring.kafka.retry.retry-backoff-msTime in milliseconds to wait before retrying a failed event3000No

Service Authentication

Property NameDescriptionType/ValueSecret?
secret-management.key-vault-uriURI for the Azure Key Vault<string>Yes
authentication.adminEmailEmail address representing the Link administrator account<string>No
authentication.anonymousWhether the service should allow anonmyous users access to the services. This should onyl be enabled for DEV environments.true or false (default)No
authentication.authorityAuthority for the service to authenticate against.http://localhost:7004No
authentication.signingKeySigning key for generating/verifying JWTs<string>Yes

HAPI FHIR Server Configuration

The HAPI module supports rate-limiting configuration to control the number of requests allowed within a specified time period. When rate-limiting is enabled, clients that exceed the configured limits will receive HTTP 429 (Too Many Requests) responses.

Property NameDescriptionType/ValueSecret?
hapi.fhir.rate-limiting.countMaximum number of requests allowed per client within the specified duration. Set to -1 to disable rate-limiting entirely.Integer (default: -1)No
hapi.fhir.rate-limiting.durationDuration for the rate-limiting window. Uses ISO-8601 duration format.Duration (default: PT1M)No

Environment Variable Examples:

  • HAPI_FHIR_RATELIMITING_COUNT=100 - Allow 100 requests per time window
  • HAPI_FHIR_RATELIMITING_DURATION=PT5M - Set time window to 5 minutes

Note: Rate-limiting is applied per client IP address. When count is set to -1 (default), no rate-limiting is applied.

Service Information

The service-information configuration allows exposing build, version and deployment information through the /api/XXX/info (i.e. /api/validation/info) endpoint of each service. This information is automatically populated from assembly metadata and git information during build time.

PropertyDescriptionRequiredDefault ValueSecret?
service-information.service-nameDisplay name of the serviceNoVaries service by serviceNo
service-information.versionVersion of the serviceNoVersion from java/maven’s BuildPropertiesNo
service-information.product-versionVersion of the product as a wholeNoN/ANo
service-information.buildBuild number from CI/CD pipelineNo”dev” when using Docker ComposeNo
service-information.commitGit commit hash of deployed versionNoNoneNo