Load feature flags from the dedicated feature flag resource endpoint - #48222
Load feature flags from the dedicated feature flag resource endpoint#48222yuanqu72 wants to merge 8 commits into
Conversation
…in the provider Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list. |
|
/azp run appconfiguration |
|
No pipelines are associated with this pull request. |
|
/azp run python - appconfiguration |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Adds dedicated feature-flag resource loading to the App Configuration provider, alongside existing key-value feature flags.
Changes:
- Adds synchronous and asynchronous loading, merging, refresh, and telemetry support.
- Adds integration/unit tests and samples.
- Updates dependency, version, changelog, documentation, and recordings.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
tests/testcase.py |
Adds resource test helpers. |
tests/test_provider_feature_flag_resources.py |
Tests synchronous resource loading. |
tests/test_configuration_client_manager.py |
Tests resource paging and ETags. |
tests/test_azureappconfigurationproviderbase.py |
Tests conversion and merging. |
tests/asynctestcase.py |
Adds asynchronous test helpers. |
tests/aio/test_async_provider_feature_flag_resources.py |
Tests asynchronous resource loading. |
setup.py |
Raises the App Configuration dependency. |
samples/README.md |
Lists the new samples. |
samples/feature_flag_resource_sample.py |
Demonstrates synchronous usage. |
samples/async_feature_flag_resource_sample.py |
Demonstrates asynchronous usage. |
README.md |
Documents resource flags and testing. |
CHANGELOG.md |
Records the feature and dependency update. |
aio/_azureappconfigurationproviderasync.py |
Integrates asynchronous loading and refresh. |
aio/_async_client_manager.py |
Adds asynchronous resource-client support. |
_version.py |
Sets version 2.6.0b1. |
_request_tracing_context.py |
Tracks filters by name. |
_constants.py |
Adds identifier and reference constants. |
_client_manager.py |
Adds synchronous resource-client support. |
_azureappconfigurationproviderbase.py |
Converts, caches, and merges resource flags. |
_azureappconfigurationprovider.py |
Integrates synchronous loading and refresh. |
assets.json |
Updates test recording assets. |
Comments suppressed due to low confidence (1)
sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationproviderbase.py:455
- An empty list is a valid refreshed result when the last resource flag is deleted, but this truthiness check leaves
_processed_resource_feature_flagsunchanged; the subsequent merge therefore keeps serving the deleted flag. TreatNoneas “not refreshed” and an empty list as “refreshed to empty” for both sources and for the merge condition.
if feature_flag_resources:
…and address review comments Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…add enhanced feature flag telemetry with tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ion to recommend FeatureFlagSelector Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…anced feature flag tracing when none are loaded Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run python - appconfiguration |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.
Suppressed comments (7)
sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationproviderbase.py:503
- An empty list is a valid refreshed result when the last resource-based flag is deleted, but this truthiness check leaves
_processed_enhanced_feature_flagsunchanged. The deleted flag therefore remains in the provider indefinitely; distinguishNone(not refreshed) from[](refreshed to empty) throughout this method and the refresh-success checks.
if enhanced_feature_flags:
self._processed_enhanced_feature_flags = [
self._process_enhanced_feature_flag(ff) for ff in enhanced_feature_flags
]
sdk/appconfiguration/azure-appconfiguration-provider/README.md:438
- This second README snippet also looks for
name, but the merged provider output exposes the identifier asid; as written, the documented example raisesStopIteration.
enhanced_flag_beta = next(flag for flag in feature_flags if flag.get("name") == "EnhancedFeatureBeta")
sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationproviderbase.py:495
- When only one feature-flag endpoint changes, this resets all filter-usage telemetry, but the code below reprocesses only the changed source. Filters from the unchanged cached source then disappear from subsequent correlation headers. Preserve usage per source or recompute telemetry from both current source sets before replacing it.
if feature_flags or enhanced_feature_flags:
# Reset feature flag usage
self._tracing_context.reset_feature_filter_usage()
sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationproviderbase.py:504
- A key-value-only refresh passes
Nonehere even when resource-based flags remain cached, so this clearsEnhFFfrom future correlation headers while those flags are still served. Derive the tag from the current cached resource-based flags instead of only the latest refresh payload.
self._tracing_context.uses_enhanced_feature_flags = bool(enhanced_feature_flags)
sdk/appconfiguration/azure-appconfiguration-provider/samples/async_enhanced_feature_flag_sample.py:82
- This async sample uses
FeatureFlagSelector, but both overloads inaio/_async_load.pystill declarefeature_flag_selectors: Optional[List[SettingSelector]]and document only that type. The advertised async usage therefore fails static type checking; update the async signatures and docstrings to the same union as the sync API.
feature_flag_selectors=[FeatureFlagSelector(name_filter="Enhanced*")],
sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_version.py:7
- Changing the package to preview version
2.6.0b1leavessetup.pyclassified asDevelopment Status :: 5 - Production/Stable. Use the Beta classifier for this prerelease; the stackedazure-appconfigurationpreview does the same in its pyproject metadata.
VERSION = "2.6.0b1"
sdk/appconfiguration/azure-appconfiguration-provider/README.md:393
- Processed resource-based flags use the Feature Management
idfield, so this lookup bynamealways exhausts the iterator and raisesStopIteration. Match the sample source and queryid.
This issue also appears on line 438 of the same file.
enhanced_flag_beta = next(flag for flag in feature_flags if flag.get("name") == "EnhancedFeatureBeta")
…ync API type hints, Python version floor, and rename tests README to avoid the package-readme section check, all addressing code review feedback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Loads feature flags from the new dedicated Feature Flag resource endpoint (
FeatureFlagClient/FeatureFlag) inazure-appconfiguration-provider, in addition to the existing key-value based feature flags.feature_flag_enabled=True, feature flags created via the feature flag resource endpoint are now loaded automatically alongside key-value based feature flags.feature_management.feature_flagslist. When a resource-based feature flag and a key-value based feature flag share the same name, the resource-based one takes precedence.load()options are required to opt in; existingfeature_flag_selectorsfilter both kinds.azure-appconfigurationto>=1.10.0b1forFeatureFlagClient/FeatureFlagsupport.Dependency on #47620
AppConfig-FFEndpointbranch), which introduces theFeatureFlagClientAPIs inazure-appconfigurationthat this change depends on. Because of that, this PR targetsAppConfig-FFEndpointinstead ofmain— the diff here is scoped only tosdk/appconfiguration/azure-appconfiguration-provider.This PR should be reviewed/merged after (or together with) #47620, once that lands in
main.Changes
_azureappconfigurationprovider.py/aio/_azureappconfigurationproviderasync.py: load and merge feature flags from the feature flag resource endpoint_client_manager.py/aio/_async_client_manager.py: new client manager support for feature flag resource clients_constants.py,_request_tracing_context.py: new constants and request tracing updates for the feature flag resource pathsamples/feature_flag_resource_sample.py,samples/async_feature_flag_resource_sample.pytests/test_provider_feature_flag_resources.py,tests/test_async_provider_feature_flag_resources.py,tests/test_azureappconfigurationproviderbase.py,tests/test_configuration_client_manager.pyCHANGELOG.md,README.md,samples/README.mdupdatedTesting