1

I am trying to integrate azure app configuration with feature flagging and have added additional filter for targeted users and groups on my azure portal.

I am using below dependency:

implementation ('com.azure.spring:spring-cloud-azure-feature-management-web:5.2.0')

Have created a TargetingContextAccessorImpl class like this:

public class TargetingContextAccessorImpl implements TargetingContextAccessor {
       
    @Override
    public void configureTargetingContext(TargetingContext context) {
            context.setUserId("charu.test@gmail.com");
            ArrayList<String> groups = new ArrayList<String>();
            groups.add("abc.com");
            context.setGroups(groups);
    }
}

Also i have created a feature flag with targetting filter on azure portal:

And my controller looks like:

 @GetMapping("/fftest")
    public String test() {
        if (Boolean.TRUE.equals(featureManager.isEnabledAsync("feature-a").block())) {
            return "enabled";
        }
        return "disabled";
    }

Now on running my application i am getting:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'Microsoft.Targeting' available

I am following this document: https://learn.microsoft.com/en-us/java/api/overview/azure/spring-cloud-feature-management-readme?view=azure-java-stable

Can anyone help with the above error log. Their is v.less information available online for Targetting.

Charu Jain
  • 852
  • 1
  • 7
  • 18

1 Answers1

1

I solved the above issue by defining another bean like this:

@Configuration
public class TargetConfiguration {

        @Bean("Microsoft.Targeting")
        public TargetingFilter targetingFilter(TargetingContextAccessor contextAccessor) {
            return new TargetingFilter(contextAccessor, new TargetingEvaluationOptions().setIgnoreCase(true));
        }
    }

This will resolve your issue. This is not clearly mentioned anywhere in docs. so required lil POC.

Hope this will help some one else.

Charu Jain
  • 852
  • 1
  • 7
  • 18