.NET 6 startup class – Dynamically update extension methods parameters without restart

Lets say I have a startup.cs class with the following extension method (.AddXYZ) from an internal team.

builder.Services.AddXYZ(builder.Configuration, o =>
{
    o.Policy.Add(new InboundPolicyOptions()
    {
        ValidApplicationIds = builder.Configuration["AllowedAppIds"].Split(',').ToList(),
    });
 });

How can I update the above ValidApplicationIds list without having to restart the server.

I have tried using Azure App Configuration to store the list of ClientIds and tried testing dynamic refresh, but it did not help.

Please suggest.

  • Without understanding what AddXYZ actually does – there is no way to tell. If you have control over the library you can rework the InboundPolicyOptions to use IOptionsMonitor for example (from the options pattern for configuration) instead of just accepting value read from the config. Or implement something similar.

    – 

Leave a Comment