Skip to content

Conversation

@zhiyuanliang-ms
Copy link
Member

@zhiyuanliang-ms zhiyuanliang-ms commented Apr 23, 2025

Why this PR?

Extends the existing SettingSelector type for AzureAppConfigurationOptions.selectors and FeatureFlagOptions.selectors.

export type SettingSelector = {
    keyFilter?: string,
    labelFilter?: string
    // New Field
    tagFilters?: string[]
    snapshotName?: string
};

Now, you can pass tag filters 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.

Usage

const config = await load(connectionString, {
    selectors: [
        { 
            keyFilter: "*",
            tagFilters: ["tag1=someValue1", "tag2=someValue2"] 
        }
    ],
    featureFlagOptions: {
        enabled: true,
        selectors: [
            { 
                keyFilter: "*",
                tagFilters: ["tag1=someValue1", "tag2=someValue"] 
            }
        ]
    }
});

Filtering for tags with empty/null value

You can construct a tag filter string like "EmptyTag=" and "NullTag=\0".

const config = await load(connectionString, {
    selectors: [
        { 
            keyFilter: "*",
            tagFilters: ["EmptyTag=", "NullTag=\0"] 
        }
    ]
});

Base automatically changed from zhiyuanliang/select-snapshot to main May 22, 2025 04:46
@avanigupta
Copy link
Member

Could you add more tests? You can refer to .net provider for different tag filter scenarios: https://github.com/Azure/AppConfiguration-DotnetProvider/blob/main/tests/Tests.AzureAppConfiguration/Unit/TagFiltersTests.cs

Also, it would be good to include usage example for filtering tags with null value/empty value. This PR description can be modified to fit your PR too: Azure/AppConfiguration-DotnetProvider#637 (comment)

@avanigupta
Copy link
Member

I dont see keyFilter specified in the usage examples in PR description. Key filter is not optional, so please make sure that missing key filter should be throwing an error. And also add key filter to the sample code snippets.

@zhiyuanliang-ms zhiyuanliang-ms merged commit e36e067 into main Aug 7, 2025
6 checks passed
@zhiyuanliang-ms zhiyuanliang-ms deleted the zhiyuanliang/tag-filter branch August 7, 2025 03:17
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.

4 participants