Skip to content

Conversation

@amerjusupovic
Copy link
Contributor

@amerjusupovic amerjusupovic commented Mar 18, 2025

Extends the existing APIs AzureAppConfigurationOptions.Select and FeatureFlagOptions.Select to have a new parameter that supports passing tags that will be used to filter key-values and feature flags. Key-values and feature flags will only be returned if they contain all of the tags and corresponding values passed to the tagFilters parameter.

Updated APIs

public AzureAppConfigurationOptions Select(
    string keyFilter, 
    string labelFilter = LabelFilter.Null, 
    IEnumerable<string> tagFilters = null)
public FeatureFlagOptions Select(
    string featureFlagFilter, 
    string labelFilter = LabelFilter.Null, 
    IEnumerable<string> tagFilters = null)

Example Usage

config.AddAzureAppConfiguration(options =>
{
    options.Select(KeyFilter.Any, LabelFilter.Null, new List<string> { "group=g1", "tag=value" });
})
config.AddAzureAppConfiguration(options =>
{
    options.UseFeatureFlags(ffOptions =>
    {
        ffOptions.Select(KeyFilter.Any, LabelFilter.Null, new List<string> { "group=g1", "tag=value" });
    });
})

Filtering for tags with empty and null value

You can use the TagValue class to filter for tags that have null value. You can also filter for empty string by constructing a tag filter string like "EmptyTag=".

Key-value as a json:

{
	"key": "TestKey",
	"label": null,
	"value": "TestValue",
	"content_type": "",
	"tags": {
		"EmptyTag": "",
		"NullTag": null
	}
}

To select key-value:

options.Select(KeyFilter.Any, LabelFilter.Null, new List<string> { "EmptyTag=", $"NullTag={TagValue.Null}" });

rossgrambo and others added 30 commits October 18, 2024 13:08
Add allocation id when telemetry is enabled for feature flag
Merge main to preview with resolved conflicts
…for refresh (#574)

* WIP

* WIP testing out client extensions methods

* WIP added selectors to multikeywatchers

* remove unused property

* WIP check for registerall changes to change refreshall

* WIP

* WIP fixing types and reslving errors

* WIP fixing client extensions class

* WIP

* WIP update feature flag logic

* WIP client extensions

* WIP reload all flags on change

* WIP

* WIP fixing tests to return response for getconfigurationsettingsasync

* WIP etag for tests

* fix watchedcollections null

* WIP tests, working for examples

* remove unused variables

* update to newest sdk version, remove unused

* WIP fixing tests

* WIP reworking testing to work with new etag approach

* tests passing, fix mockasyncpageable

* update sdk package version

* fix loghelper, tests

* WIP fixing aspages tests

* revert watchesfeatureflags test

* update test again

* WIP

* fixing watchconditions

* separate selected key value collections from feature flag collections, separate selectors, add new methods to support new logic

* comment and naming updates

* fixing unit tests, namespace of defining/calling code needs to be same

* fixing tests using AsPages

* fix tests with pageablemanager

* format

* fix tests

* fix tests

* remove unused extension test class

* fix comment, capitalization

* check etag on 200, fix tests

* add registerall test, fix refresh tests

* fix condition for pages and old match conditions

* WIP fixing PR comments, tests

* check status after advancing existing etag enumerator

* move around refresh logic

* null check page etag, revert break to existing keys check in getrefreshedcollections

* fix loadselected, replace selectedkvwatchers with registerall refresh time

* fix comment in options

* clean up tests

* PR comments

* PR comments

* don't allow both registerall and register

* fix check for calls to both register methods

* PR comments for rename/small changes

* fix compile error

* simplify refreshasync path, fix naming from comments

* remove redundant if check

* simplify logic for minrefreshinterval

* fix smaller comments

* call loadselected when refreshing collection, separate data for individual refresh

* in progress change to registerall include ff

* fix load order

* fix comments, rename logging constants to match new behavior

* pr comments, refactor refreshasync

* clean up etags dictionary creation

* PR comments

* add uncommitted changes to testhelper

* update tests for registerall with feature flags, check ff keys to remove flags on refresh

* PR comments

* PR comments

* use invalidoperationexception in configurerefresh, update loggingconstants to match behavior

* remove unused changes
…nstance(s) used by the provider (#598) (#617)

* Introduced a new `AzureAppConfigurationClientFactory` class to handle the creation of `ConfigurationClient` instances

* remove clients dictionary since we will not have hits and clients are already stored in ConfigurationClientManager

* revert

* add license + remove unused usings

* ran dotnet format

* add capability of fallback to different stores

* add explicit type

* address comments

* remove scheme validation

---------

Co-authored-by: Sami Sadfa <71456174+samsadsam@users.noreply.github.com>
Co-authored-by: Sami Sadfa <samisadfa@microsoft.com>
avanigupta
avanigupta previously approved these changes Apr 17, 2025
@avanigupta
Copy link
Member

Can you also update the PR description with the right parameter name?

@amerjusupovic
Copy link
Contributor Author

Can you also update the PR description with the right parameter name?

Thanks, updated

jimmyca15
jimmyca15 previously approved these changes Apr 17, 2025
@amerjusupovic amerjusupovic changed the base branch from preview to main April 24, 2025 16:20
@amerjusupovic amerjusupovic dismissed stale reviews from jimmyca15 and avanigupta April 24, 2025 16:20

The base branch was changed.

@amerjusupovic
Copy link
Contributor Author

amerjusupovic commented Apr 24, 2025

Removed preview changes after changing target branch to main

@amerjusupovic amerjusupovic merged commit e09cb23 into main May 2, 2025
3 checks passed
@amerjusupovic amerjusupovic deleted the ajusupovic/tag-filtering branch May 2, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants