H.Necessaire Runtime Configuration Reference

How RuntimeConfig works and every configuration key the library reads, with defaults.

Applies to H.Necessaire 4.0.5.

H.Necessaire reads its settings from a RuntimeConfig: a tree of named nodes. This article explains how to provide one and lists the keys the library reads.

The config model

class ConfigNode
{
    string ID { get; set; }
    MultiType<string, ConfigNode[]> Value { get; set; }   // a string, or child nodes
    ConfigNode Get(string id);
    ConfigNode[] GetAll();
    string[] GetAllStrings();
}

class RuntimeConfig
{
    ConfigNode Get(string id);
    ConfigNode[] Values { get; set; }
}

IDs are matched case-insensitively. A node's value is either a string or a list of child nodes, so QdActions.MaxProcessingAttempts in this article means the node MaxProcessingAttempts under the node QdActions.

Providing a config

The ConfigWith string extension builds nodes:

var config = new RuntimeConfig
{
    Values = new[]
    {
        "App".ConfigWith(
            "Name".ConfigWith("My App")
        ),
        "QdActions".ConfigWith(
            "ProcessingIntervalInSeconds".ConfigWith("5"),
            "MaxProcessingAttempts".ConfigWith("5")
        ),
    }
};

deps.Register<RuntimeConfig>(() => config);

You can also implement ImAConfigProvider (RuntimeConfig GetRuntimeConfig()). With Integration.DotNet, IConfiguration (appsettings.json, environment variables and so on) is bridged into a provider for you. Code reads the result through dependencyProvider.GetRuntimeConfig(), which prefers a registered ImAConfigProvider, then a registered RuntimeConfig, then an empty config.

For secrets, ConfigWithSecretFromEmbeddedResources(secretName, assemblies) reads the value from an embedded resource instead of a string literal.

General

KeyDefaultNotes
App.Name"H.Necessaire"Application name stamped on every log entry.
DefaultHasherSimpleSecureHasherAlso available: MD5Hasher; the runtime additionally registers RS512Hasher.
Cryptography.AesKeybuilt-in default keyBase64 key for the default ImACryptographer. Set your own in any real deployment.
Cryptography.CaesarCipherKeybuilt-in default keyBase64 key for the Caesar cipher cryptographer.
CachingHousekeepingIntervalInSecondsinternal defaultHow often cache housekeeping runs.
HttpBaseUrl, HttpApiBaseUrlnoneBase URLs used by the runtime's HTTP service.

QD actions

KeyDefault
QdActions.MaxProcessingAttempts3
QdActions.ProcessingIntervalInSeconds15
QdActions.ProcessingBatchSize10

File system and security

KeyDefault
FileSystemStorageRootFolderderived from the start assembly's folder
IronMen.FilePathironmen.json
IronMen.PassFilePathironmen.pass.json
AppDataFolderPathnone; required by the SQLite data bin storage

Storage providers

SQL (Dapper-based providers)

  • SqlConnections.DefaultConnectionString
  • SqlConnections.DatabaseNames.Core

RavenDB

  • RavenDbConnections.DatabaseNames.Core
  • RavenDbConnections.DatabaseUrls: a list of URLs
  • RavenDbConnections.ClientCertificateName: the PFX certificate must be an embedded resource
  • RavenDbConnections.ClientCertificatePassword: if the certificate is password protected
  • RavenDbConnections.ColdArchiving: an optional node for the cold archiving store

Azure Cosmos DB

  • AzureCosmosDB.URL
  • AzureCosmosDB.Keys: a list
  • AzureCosmosDB.DatabaseID
  • AzureCosmosDB.ContainerID
  • Optional application name under AzureCosmosDB.App, .Application, .AppName or .ApplicationName

Google Firestore

  • Google.Firestore.ProjectID
  • Google.Firestore.HNecessaireDefault: optional collection name, defaulting to HNecessaireDefault
  • Google.Firestore.Auth.Json: path to the Google auth JSON, which you can skip if GOOGLE_APPLICATION_CREDENTIALS is set

UI and CLI (from the project README)

These keys are documented in the repository README and weren't re-verified against the source for this article: BaseUrl, BaseApiUrl, SecurityContextCheckIntervalInSeconds (30), SyncIntervalInSeconds (10), the Formatting.* date and time patterns, Security.LoginUrl, Security.RefreshUrl, BffApiSyncRegistryRelativeUrl and the CLI's NuSpecRootFolderPath.