Discovery
Preliminary information
Overview
ASOL.Core.Discovery adds a configuration provider that loads application settings from an external Discovery service during startup.
The package is intended for services that need centralized remote configuration resolved through service-to-service authentication.
Install
ASOL.Core.Discovery
Usage
The main entry point is the AddExternalConfiguration(...) extension for IConfigurationBuilder.
using ASOL.Core.Discovery.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddExternalConfiguration(builder.Environment);
This overload reads required settings from the existing configuration and uses them to connect to Discovery:
SsoAuthConfigurationServiceOptions
Minimal configuration example:
{
"SsoAuth": {
"Authority": "https://avaplace.com/api/asol/idp",
"Audience": "apiim",
"ClientId": "MyService",
"ClientSecret": "secret"
},
"ConfigurationServiceOptions": {
"DiscoveryUrl": "https://avaplace.com/api/asol/discovery"
}
}
You can also initialize the provider explicitly:
using ASOL.Core.Discovery;
using ASOL.Core.Discovery.Extensions;
using ASOL.Core.Discovery.Options;
using ASOL.Core.Identity.Options;
builder.Configuration.AddExternalConfiguration(builder.Environment, cfg =>
{
cfg.AuthOptions = new SsoAuthOptions
{
Authority = "https://avaplace.com/api/asol/idp",
Audience = "apiim",
ClientId = "MyService",
ClientSecret = "secret"
};
cfg.ServiceOptions = new ConfigurationServiceOptions
{
DiscoveryUrl = "https://avaplace.com/api/asol/discovery"
};
});
Behavior
During startup the provider obtains an access token using client credentials, calls the configured Discovery endpoint, and loads returned key-value pairs into application configuration.
Configuration precedence is intentionally layered:
- in non-development environments, remote Discovery configuration is added after file-based configuration
- in development,
appsettings.Development.jsonis added again after Discovery, so a developer can override remote values locally - environment variables are added last and can override both local and remote values
If required settings are missing, provider initialization fails with an argument exception. If the remote service is temporarily unavailable, the provider retries loading until the startup timeout is reached.