Sphyrnidae Common Library  2.0.1
Shared Utilities/Library
Environmental Settings

Overview

Environmental settings are settings/configurations that are specific to an environment. Typical environments are:

  1. Dev
  2. QA
  3. Production

Any settings that will be unique to a certain environment should be stored as an environmental variable. Examples:

  1. URL's to other services/applications in that environment
  2. Caching settings
  3. Connection strings

.Net Core has the IConfiguration interface. The IEnvironmentSettings is the basis for this. In fact the implementation merely calls this interface. So if you'd prefer to just use the IConfiguration interface, then that is perfectly fine.

Interface: IEnvironmentSettings

Mock: EnvironmentalSettingsMock

Implementation: EnvironmentalSettings

Where Used

Class Name of Configuration Default Value Description
IpAddress ASPNETCORE_ENVIRONMENT If "localhost", then use 127.0.0.1
CacheLocalAndDistributed Cache:Distributed true Purely for this caching implementation, specifies if distributed caching is enabled
CacheLocalAndDistributed Cache:Local true Purely for this caching implementation, specifies if local caching is enabled
LogRepo.CnnStr Cnn:Logging Encrypted connection string to the logging database
EncryptionKeyManager Encryption_Key current encryption key
EncryptionKeyManager Encryption_Key_Old Previous encryption key
HttpDataMiddleware Require_Https false If your application requires all requests be secure (HTTPS)
ApiAuthenticationWebService.Url URL:ApiAuthentication URL to the Authentication microservice (API<=>API)
FeatureToggleWebService.Url URL:FeatureToggle URL to the Feature Toggle microservice
SignalR URL:Hub:Cache For CacheLocalAndDistributed, when you clear cache, this is the URL to SignalR which will then publish a clear cache message to other applications to clear their local cache
CacheDistributed and CacheLocalAndDistributed URL:Redis Distributed caching URL
UserPreferenceWebService.Url URL:UserPreferences URL to the User Preferences microservice
VariableWebService.Url URL:Variable URL to the Variable microservice
HealthCheck version Assembly.GetEntryAssembly()?.GetName().Version For the health check endpoint (/hc) to list the current version of the application

Examples

    // Note that the nested structure in appsettings.json get converted to ":" at each level
    // <a><b><c>123</c></b></a>
    IEnvironmentSettings env; // Should be injected
    SettingsEnvironmental.Get(env, "a:b:c", "default value"); // 123