I am learning Azure App Configuration - Feature manager.
I am trying to understand if a custom feature filter that we write needs to use some parameters which are not part of HttpContext.
How can we pass extra parameters when we call IFeatureManager.IsEnabled("featurename") which triggers Evaulate method of custom filter.
But how an azure function app or webjob will use it.
[FilterAlias("AllowedUsers")]
public class AllowedUsersFeatureFilter : IFeatureFilter
{
private readonly IHttpContextAccessor _httpContextAccessor;
public AllowedUsersFeatureFilter(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
// HOW CAN WE PASS SOME parameter when we call IFeatureManager.IsEnabled("featurename")
public bool Evaluate**(FeatureFilterEvaluationContext context)**
{
var featureFilterParams = context.Parameters.Get<AllowedUsersFilterSettings>();
if (featureFilterParams == null)
return false;
var userEmail = _httpContextAccessor.HttpContext.User?.FindFirst(ClaimTypes.Upn)?.Value;
var alias= userEmail?.Split('@').First();
return featureFilterParams.Aliases.Split(',').Contains(alias, StringComparer.OrdinalIgnoreCase);
}
}