Skip to content

Potential bug: Propagating App Service environment variables through IFeatureManager #254

Closed
@aatrisgn

Description

@aatrisgn

Hi,

I am experiencing some weird behaviour utilizing IFeatureManager on a regular Linux S1 App Service with Azure App Configuration integration via managed identity.

In short, it seems like IFeatureManager propagates some configuration of our App Service instance when no Feature Toggles are defined in Azure App Configuration for our application.

We have two scenarios for our usage:

  1. An application has one or more feature flags enabled in Azure App Configuration
  2. An application has no feature flags enabled in Azure App Configuration

We are exposing the feature flags via a configurations endpoint for our frontend application. Our feature flags are not sensitive information, but only for UX.

Our feature flags will only be defined in Azure App Configuration for deployed Azure environments. Locally, we handle it differently.

Problem
What we experience are the following three things:

  1. An environment has one or more feature flags enabled:
    image

Feature flag is correctly exposed to our frontend.

  1. An environment has disabled feature flags:
    image

We do not expose any feature flags - This is fine behaviour as well.

  1. We have not deployed any feature flags (Where the problem lies):
    image

This is problematic. We do not want to expose what seems to look like App Service configuration for our feature flags. It seems weird to me, that this is exposed via IFeatureManager. I can read in the documentation that IFeatureManager exposes environment settings as well, but I wouldn't expect it to do so, unless explicitly defined.

Our application code for Azure App Configuration looks like the following:

webApplicationBuilder.Services.AddFeatureManagement();

if (appConfigEndpoint != null) {
    webApplicationBuilder.Configuration.AddAzureAppConfiguration(options =>
        options.Connect(
            new Uri(appConfigEndpoint),
            new ManagedIdentityCredential(managedIdentityId))
    .UseFeatureFlags(featureFlagOptions => featureFlagOptions.CacheExpirationInterval = TimeSpan.FromMinutes(5)));
}

We expose our Feature Flags to our frontend via the following:

var featureDictionary = new Dictionary<string, bool>();

IAsyncEnumerable<string> availableFeatures = _featureManager.GetFeatureNamesAsync();

await foreach (string feature in availableFeatures) {
    if (await _featureManager.IsEnabledAsync(feature)) {
        featureDictionary.Add(feature, true);
    }
}

return featureDictionary;

As for now, we have a work-around, but we were a bit surprised by this behaviour. In our case, it werent critical information which was exposed, but if it had been a connectionstring or similar, that would have been problematic.

My question therefore is, whether this is intentional behaviour? If so, what is your recommended way of handling a scenario where you only sometimes have feature flags defined and needs to expose them?

Please let me know, if you need anything further information.

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions