IFeatureManager.IsEnabledAsync() always returns the same (cached) value

1.5k Views Asked by At

The IsEnabledAsync() method on Microsoft.FeatureManagement.IFeatureManager will always return the same cached value. For example, I can put the following code inside of an ASP.NET Core IHostedService in a repeated timer, every time IsEnabledAsync is called for a feature, it returns the same value it did when it started. I can toggle the feature in Azure and it will still return the cached (incorrect) value. Only when I restart the app does it correctly acquire the feature setting. Is this a bug with the IFeatureManager or is there a better way to do this? I've submitted a github issue just incase.

    var features = await _featureManager.GetFeatureNamesAsync()
        .ToListAsync();

    var enabledFeatures = await features.SelectAsync(async f =>
    {
        var enabled = await _featureManager.IsEnabledAsync(f);
        return enabled ? f : null;
    });

enter image description here

0

There are 0 best solutions below