英文:
Azure app config feature flagging for targetted users and groups not working
问题
我正在尝试将Azure应用配置与特性标志集成,并在Azure门户上为定向用户和群组添加了附加筛选器。
我正在使用以下依赖项:
implementation ('com.azure.spring:spring-cloud-azure-feature-management-web:5.2.0')
已创建了一个类似于以下的TargetingContextAccessorImpl类:
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);
}
}
我还在Azure门户上创建了一个带有定向筛选器的特性标志。
我的控制器如下:
@GetMapping("/fftest")
public String test() {
if (Boolean.TRUE.equals(featureManager.isEnabledAsync("feature-a").block())) {
return "enabled";
}
return "disabled";
}
现在,在运行我的应用程序时,我遇到了以下错误:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'Microsoft.Targeting' available
我正在遵循此文档:https://learn.microsoft.com/en-us/java/api/overview/azure/spring-cloud-feature-management-readme?view=azure-java-stable
是否有人可以帮助解决上述错误日志?关于Targeting,在线上的信息相对较少。
英文:
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.
答案1
得分: 1
我通过定义另一个bean来解决了上述问题,代码如下:
@Configuration
public class TargetConfiguration {
@Bean("Microsoft.Targeting")
public TargetingFilter targetingFilter(TargetingContextAccessor contextAccessor) {
return new TargetingFilter(contextAccessor, new TargetingEvaluationOptions().setIgnoreCase(true));
}
}
这将解决您的问题。这在文档中并没有明确提到,因此需要进行一些小的验证性实验。
希望这对其他人有所帮助。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论