ROAD Backend
1.14 1.13 1.12
1.14 1.13 1.12

Configuration Parameters (MAM Adapter Service)

The MAM Adapter Service is based on Microsoft .Net Core. Microsoft, which offers the following built-in ways for specifying configuration:

  • appsettings.json file (lowest priority)

  • environment variables

  • command-line options (highest priority)

With this it’s possible to have a default configuration in the settings file, but override selected parameters. See also https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-7.0

Configuring an option in appsettings.json

Example: Settings | WatchFolder

{
...
  "Settings": {
    "WatchFolder": "C:\Temp",
  }
...
}

Configuring an option with environment variables

Example: Settings | WatchFolder

According to the hierarchical structure of appsettings.json options the environment variable name is derived by adding double underscores between hierarchies

set Settings__WatchFolder=C:\Temp

Configuring an option from command line

Example: Settings | WatchFolder

According to the hierarchical structure of appsettings.json options the command-line option name is derived by adding a colon between hierarchies

dotnet DpeNanoServices Settings:WatchFolder=C:\Temp

Plugin Settings and MamLogging Setting

The configuration root name is defined by the plugin; logging settings appear in the section named “MamLogging”.

Example:

{
...
  "DpeAdapter": {
    "DpeUrl": "https://...",
    ...
  }
  "MamLogging": {
    "MinimalLevel": "D",
    ...
  }  
...
}

Overriding settings from the command line

You can override a setting from the command line (or an environment variable), but only if the key already exists in appsettings.json. The command line changes an existing value — it can't add a new one. If you override a key that isn't in the file, it's silently ignored.

The reason: the service reads the JSON entry to know both that the setting exists and what type it is (number, text, yes/no). A command line only carries text, so the JSON entry is what tells the service how to interpret the value. No entry → nothing to attach to and no known type.

So to make a parameter tunable at runtime, add it to appsettings.json once (with any sensible default), then override it at start:

  • Command line: DpeAdapter:DpeUrl=https://myNewUrl/..

  • Environment variable: DpeAdapter__DpeUrl=https://myNewUrl/.. (double underscore = the :)

The original type is preserved — a number stays a number, a true/false stays a boolean.