Storing Configuration in YAML, JSON etc.

Some Consul users prefer storing configuration in blobs of a certain format, such as YAML. Micronaut supports this mode and supports storing configuration in either YAML, JSON or Java properties format.

The ConfigDiscoveryConfiguration has a number of configuration options for configuring how distributed configuration is discovered.

You can set the consul.client.config.format option to configure the format with which properties are read.

For example, to configure JSON:

application.yml

  1. consul:
  2. client:
  3. config:
  4. format: JSON

Now write your configuration in JSON format to Consul:

Using curl write JSON

  1. curl -X PUT localhost:8500/v1/kv/config/application \
  2. -d @- << EOF
  3. { "foo": { "bar": "myvalue" } }
  4. EOF