spring-bootazureazure-app-configurationazure-feature-manager

How to get the value of Azure App Configuration Feature Flag with specific label from Spring boot?


I started using Azure App Configuration service and Feature Flags functionality in my project. I followed this documentation and was able to create a Spring boot project. I also created a FeatureFlagService class and autowired the FeatureManager class in it as shown below :

@Service
public class FeatureFlagService {

  private FeatureManager featureManager;

  public FeatureFlagService(FeatureManager featureManager) {
     this.featureManager = featureManager;
  }

  public boolean isFeatureEnabled() {
     return featureManager.isEnabledAsync("scopeid/MyFeature").block();
  }

}

With this I get the value of the feature flag 'MyFeature' but with no label. I have the same feature defined with different labels in Azure App Configuration as shown below.

enter image description here

I need to fetch the feature flag with specific label. How can I achieve it at runtime? I don't see a way to do it using the FeatureManager class.


Solution

  • They only way to load from a label is by using spring.cloud.azure.appconfiguration.stores[0].feature-flags.label-filter, the Feature Management Library itself has no concept of a label.