0

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.

pranay jain
  • 352
  • 1
  • 2
  • 15

1 Answers1

0

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.

mrm9084
  • 430
  • 1
  • 3
  • 12
  • Hi @mrm9084, I intend to get the labels at run time. The property `spring.cloud.azure.appconfiguration.stores[0].feature-flags.label-filter` goes in bootstrap.properties files. I found that if I use a low level dependency `azure-data-appconfiguration`, I can potentially fetch all the features with a specific label at run time. Reference : https://learn.microsoft.com/en-us/java/api/overview/azure/data-appconfiguration-readme?view=azure-java-stable. The disadvantage of using this is to give up the Spring boot features. – pranay jain Apr 13 '22 at 06:37
  • Azure App Configuration Labels map to Spring profiles. You may be able to find something to help here https://microsoft.github.io/spring-cloud-azure/docs/azure-app-configuration/index.html, it is the complete documentation for both Spring libraries. – mrm9084 Apr 13 '22 at 16:44