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 <[email protected]>
Co-authored-by: Sami Sadfa <[email protected]>
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
zhiyuanliang-ms added a commit that referenced this pull request Nov 12, 2025
* Use TryAddSingleton instead of AddSingleton for extension (#643)

* use TryAddSingleton instead of AddSingleton in extension, fix refresherprovider accordingly

* remove unused using

* add comment

* Fix format (#647)

* fix format

* fix format

* fix format

* fix format

* Add request tracing for content type (#646)

* add initial content type pattern

* format fix

* fix comment

* update to account for chat completion vs ai profiles

* in progress fix adapter to use existing requesttracingoptions

* use content type tracing to pass to requesttracingoptions

* fix comments and naming

* remove unneeded file

* add check for request tracing enabled

* check content type in preparedata

* remove errors

* fix spacing

* fix test

* remove unused usings, add back catch for .net framework

* fix parsing

* rename constants

* fix indent

* update for PR comments

* PR comments, update if conditions

* add isjson check

* update isjson extension

* Fix test to use new refresh interval api (#650)

* fix test to remove obsolete

* change variable names

* Separate content type exclusion logic from IsJson extension (#651)

* fix isjson and separate exclusion logic

* update adapters to use new extension

* PR comments

* update package versions to 8.1.2 (#648)

* Revert "Shorten the defeult timeout of individual call to backend (#620)" (#653)

This reverts commit 87f0f85.

* Add activity source to allow OpenTelemetry to collect tracing (#645)

* add activity source

* add minimum requirement for MinBackOffDuration

* Revert "add minimum requirement for MinBackOffDuration"

This reverts commit 59d847a.

* revert make MinBackoffDuration public

* update

* update activity name

* update

* Removed FeatureFlagId

* Add support for filtering by tags (#637)

* Adding allocation id

* serialize with sorted keys

* use string empty

* nit

* rename ff id to TelemetryVariantPercentile

* add more values

* dotnet format

* Version bump

* Add `RegisterAll` API to enable monitoring collections of key-values 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

* Give the users the ability to have control over ConfigurationClient instance(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 <[email protected]>
Co-authored-by: Sami Sadfa <[email protected]>

* first draft tag filtering support

* add alternate APIs

* change to use ienumerable

* update featureflagoptions to match main options

* update keyvalueselector equals and hashcode

* update param comments for selects

* fix merge conflict errors

* add validation for tagsfilter param, add to comment

* edit error message for format

* edit comment

* add unit tests

* remove unused file

* revert versions

* update tests to include feature flag select

* add refresh test

* ff only refresh test

* update equals for selector

* fix equals

* update equals

* reorder properties in keyvalueselector

* upgrade to 8.2.0-preview (#638)

* fix incorrect test

* fix equals for selector

* update gethashcode for keyvalueselector

* PR comments, in progress

* update tests from PR comments

* add validation for number of tags, add test

* rename tagsFilter to tagsFilters everywhere

* fix usings, missing updates to ffoptions

* update ffoptions select again

* fix tests

* update sdk version

* update tagsfilters to tagfilters

* remove tagsfilters again

* PR comments

* PR comments

* Revert "Merge pull request #600 from Azure/rossgrambo/allocation_id"

This reverts commit 51d4ad7, reversing
changes made to d551536.

* Revert "Give the users the ability to have control over ConfigurationClient instance(s) used by the provider (#598) (#617)"

This reverts commit 6dc9ae2.

---------

Co-authored-by: Ross Grambo <[email protected]>
Co-authored-by: Sami Sadfa <[email protected]>
Co-authored-by: Sami Sadfa <[email protected]>
Co-authored-by: Sami Sadfa <[email protected]>

* Clarify client factory comment (#660)

* add comment to setclientfactory

* update comment

* update comment

* Shorten default timeout of individual calls to backend (#657)

* in progress fix shorten timeout PR

* dispose httpclienttransport

* remove unnecessary check

* fix disposal pattern

* fix static compile error

* remove unused using

* reset options

* fix options

* add line to options

* use retryoptions.networktimeout

* add test, update isfailoverable

* update test comment

* update test

* remove check for nested taskcanceledexception

* simplify if statement in isfailoverable

* renormalize options

* update package versions to 8.2.0 (#662)

* Add .gitattributes and normalize line endings (#661)

* add gitattributes and renormalize any files

* newline end of file

* file start with mit license

* fix typo

* update to 2023-11-01 (#663)

* Add integration testing (#634)

* add initial integration test file

* update auth

* add skipping

* organize tests into unit and integration

* update formatting

* WIP create config store

* edit

* update integration setup

* copilot updates

* initial working version of integration tests

* remove obsolete tags and update formatting

* updating tests

* format

* remove skipping, add tests

* add cleanup stale resource call on startup and dispose

* add back removed line

* use persistent resource group

* add ordering of apis test

* add refresh test

* add tests

* add failover test

* adding snapshot tests first draft

* fix snapshot tests

* add key vault tests

* add more keyvault tests

* fix keyvault tests

* add cleanup of key values/secrets/snapshot

* fix key vault isolation

* remove base exception catches

* update ci.yml to work with integration tests and use github repo secrets

* add id token write permission

* update ci.yml step to create subscription file

* edit ci.yml

* fix github action

* update comment in powershell script

* remove unused packages

* update comment, remove unused methods

* add request tracing test

* check for status code in catch, move cleanupstaleresources call to dispose

* PR comments

* comments

* comments

* update copilot instructions

* update copilot instructions

* fix try blocks to only surround throwing code

* fix setuptestkeys, simplify comments and setup code

* tagfilters integration test in progress

* tagfilters integration test in progress

* correct api version

* fixed tagfilter test

* fix requesttracing test

* allow commas in json reader

* stale threshold

* remove copilot instructions

* use outputhelper

* fix cleanupstale

* update setup method, remove flag

* Support health check (#644)

* support health check

* update

* reord last successful time in ExecuteWithFailoverPolicy

* make health check compatible with DI

* add health check for each provider instance

* update

* update comment

* Undo package version change

* Add Copilot instructions (#667)

* add copilot instructions

* fix grammar

* Update .github/code-gen-instructions.md

Co-authored-by: Jimmy Campbell <[email protected]>

---------

Co-authored-by: Jimmy Campbell <[email protected]>

* Add CodeQL exclusions for code samples

* Fix ConfigStoreDemo sample for CodeQL alerts (#677)

* initial fixes to jquery for codeql alerts

* add other wwwroot files

* remove comment

* redo line endings on configstoredemo sample files

* update site css to fit title

* fix title spacing

* update to aspnet ajax instead

* Add testcase for refresh activity (#665)

* add testcase for refresh activity

* update

* update

* update

* Add environment variable to disable feature management schema compatibility logic (#676)

* add environment variable, unit test

* remove comments

* Update src/Microsoft.Extensions.Configuration.AzureAppConfiguration/FeatureManagement/FeatureManagementKeyValueAdapter.cs

Co-authored-by: Copilot <[email protected]>

* fix unit test

* update comments

* move bool parsing logic outside try

* fix formatting

* add environment variable class

* update

* update

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Zhiyuan Liang <[email protected]>
Co-authored-by: Zhiyuan Liang <[email protected]>

* version bump 8.3.0 (#682)

* Merge pull request #684 from Azure/zhiyuanliang/fix-test

Fix activity source test bug

* Fix bug with endpoint failover (#686)

* update endpoint in do while

* add test

* in progress

* update test, update logic to backoff using correct endpoint

* make test more specific

---------

Co-authored-by: AMER JUSUPOVIC <[email protected]>
Co-authored-by: Amer Jusupovic <[email protected]>

* Support comment in json key value (#685)

* support jsonc

* remove unused reference

* use private static option

* Add request tracing for Aspire usage (#687)

* add request tracing for aspire component

* update tag name

* version bump 8.4.0 (#690)

* Adding Snapshot References Feature (#689)

* feat: defined snapshot reference content type and Json Property

* added snapshot reference content type to content type extensions

* updated the snapshot reference content type to include the charset

* Implementing snapshot references

* Fixed the behavior of an edge case and moved file to a better location in repo

* created unit tests for Snapshot References

* Removed unnecessary comments from tests

* removed extra comments and cleaned up code

* modified test and added set up for testing snapshot references

* adding more integration tests for snapshot references

* removed client and cancellation token from snapshot reference class and updated all affected code

* updated namespaces for all files and created parser class

* additional file to update namespace

* Modified the code to directly use the content type instead of copying

* Used object initializer pattern and passed in cancellationTokens to async methods

* fixed comment and updated TestContext format

* updated behavior to throw exception if snapshot name is null

* Moved the exception error messages from inline to ErrorMessages class and renamed parsing method to Parse()

* Added Request tracing and case for snapshot reference is registered for refresh by not called in select

* added test case to test adding snapshot reference to register but not part of select

* updating request tracing to only tracking use of snapshot references

* removing request tracing logic for Snapshot References count

* added comments and returning SnapshotReference type from Parse()

* removed second way of checking for snapshot references type and updated test cases

* removed redundant error message

* removed unnecessary code

* fixed whitespace issues and made error message clearer

* updating naming and removing old telemetry code

* updated namespace and directory to SnapshotReference

* Added new JsonFields type

* fixed error regarding same namespace and type

* Updated the Parse logic to handle all exceptions instead of LoadSnapshotData

* updated comments to method

* removed the update and reset snapshot reference request tracing methods as they were unnecessary

* removed requestTracing for SnapshotReference from refresh

* reverting previous change

* Made these keyvault integration tests more resilient

* Cleaning up code

* More nit changes

* updated request tracing for snapshot references in refresh

* making the key vault integration test more resilient

* correction to which test needed resilience

* Merge pull request #695 from Azure/zhiyuanliang/upgrade-dependency

Drop .net 6 & Upgrade dependency

* Fix integration test bug (#697)

* delete kv sequentially

* fix snapshot creation and deletion bug

* fix

* update retention period

* Add AddAzureAppConfiguration overload to take endpoint and entra id (#694)

* add overload to take endpoint and credential

* enrich comment for intellisense

* update comment to point to use options.connect pattern

* update

* Merge pull request #700 from Azure/zhiyuanliang/dummy-health-check

Add AlwaysHealthy health check when provider is disabled

* Support Azure Front Door (#706)

* wip

* wip

* wip

* wip

* fix test

* wip

* wip

* wip

* add test

* update correlation context

* update

* only check response time for refresh trigger engine

* disallow sentinel key refresh for AFD

* add feature flag refresh test

* update

* resolve comments

* update

* update error message

* upgrade sdk version

* update test

* version bump 8.5.0-preview (#708)

---------

Co-authored-by: Amer Jusupovic <[email protected]>
Co-authored-by: Ross Grambo <[email protected]>
Co-authored-by: AMER JUSUPOVIC <[email protected]>
Co-authored-by: Sami Sadfa <[email protected]>
Co-authored-by: Sami Sadfa <[email protected]>
Co-authored-by: Sami Sadfa <[email protected]>
Co-authored-by: Jimmy Campbell <[email protected]>
Co-authored-by: Richard Muniu <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: t-vvidyasaga <[email protected]>
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