Spring: Azure Feature Manager Feature toggles Microsoft.Targeting bean not found

286 Views Asked by At

I am currently having a problem with the Azure feature manager. I used the following tutorial to add a feature toggle to my application: Link

This is working fine as long as we are talking about a manually set feature flag. As soon as the type of the feature is set to "Targeting" in Azure, the following code will result in an error.

featureManager.isEnabledAsync(FeatureToggle.OUR_FEATURE_TARGETING.key).block()

Specifically we will get No bean named 'Microsoft.Targeting' available in the spring error log. A client trying to acces an endpoint containing the above code will get a 500 with the error message Fail fast is set and a Filter was unable to be found: Microsoft.Targeting


Additional info

I am using Kotlin and Spring.

Setting the feature to "Time Based" will result in an error aswell.

The service calling the feature manager looks like this

@Autowired
private lateinit var featureManager: FeatureManager

fun feature(): String {
        if (featureManager.isEnabledAsync(FeatureToggle.OUR_FEATURE_TARGETING.key).block() == true) {
            return "feature A!"
        } else {
            return "feature B!"
        }

And the FeatureToggle Enum looks like this

enum class FeatureToggle(val key: String) {
    OUR_FEATURE_TARGETING("feature")
}
1

There are 1 best solutions below

0
mrm9084 On

It doesn't go over it in that guide, but the built in Feature Flags are not configured to be on by default, then need to be built in an @Configuration file. More info can be found here https://microsoft.github.io/spring-cloud-azure/docs/azure-app-configuration/2.3.0/reference/html/index.html#built-in-feature-filters