Assume you have the following data in your appsettings.json
{
"MyData":
{
"BaseUrl": "https://example.com"
}
}
Create a class to map these settings
public class MyData
{
public string? BaseUrl { get; set;}
}
Register in the DI
builder.Services.AddOptions().Configure<MyData>(builder.Configuration.GetSection("MyData"));
Inject in controller (or wherever)
IOptions<MyData> settings