Skip to content

Commit a6ecffd

Browse files
Merge pull request #304905 from zhiyuanliang-ms/zhiyuanliang/dotnet-fm-4.3.0
Azure App Configuration - .NET FM 4.3.0 feature doc
2 parents b9b00f7 + 7035786 commit a6ecffd

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

articles/azure-app-configuration/feature-management-dotnet-reference.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,63 @@ A `requirement_type` of `All` changes the traversal. First, if there is no filte
140140

141141
In this example, `FeatureW` specifies a `requirement_type` of `All`, meaning all of its filters must evaluate to true for the feature to be enabled. In this case, the feature is enabled for 50% of users during the specified time window.
142142

143+
#### Handling multiple configuration sources
144+
145+
Starting with v4.3.0, you can opt in to custom merging for Microsoft schema feature flags (the `feature_management` section). When the same feature flag ID appears in multiple configuration sources, the built-in `ConfigurationFeatureDefinitionProvider` merges those definitions according to configuration provider registration order. If there's a conflict, the last feature flag definition wins. This behavior differs from .NET's default array index-based merging.
146+
147+
The following example demonstrates how to enable custom feature flag configuration merging through dependency injection.
148+
149+
```C#
150+
IConfiguration configuration = new ConfigurationBuilder()
151+
.AddJsonFile("appsettings.json")
152+
.AddJsonFile("appsettings.prod.json")
153+
.build();
154+
155+
services.AddSingleton(configuration);
156+
services.AddFeatureManagement();
157+
services.Configure<ConfigurationFeatureDefinitionProviderOptions>(o =>
158+
{
159+
o.CustomConfigurationMergingEnabled = true;
160+
});
161+
```
162+
163+
You can also enable it when constructing the `ConfigurationFeatureDefinitionProvider`
164+
165+
```C#
166+
var featureManager = new FeatureManager(
167+
new ConfigurationFeatureDefinitionProvider(
168+
configuration,
169+
new ConfigurationFeatureDefinitionProviderOptions
170+
{
171+
CustomConfigurationMergingEnabled = true
172+
}));
173+
```
174+
175+
Example behavior:
176+
177+
```javascript
178+
// appsettings.json
179+
{
180+
"feature_management": {
181+
"feature_flags": [
182+
{ "id": "FeatureA", "enabled": true },
183+
{ "id": "FeatureB", "enabled": false }
184+
]
185+
}
186+
}
187+
188+
// appsettings.prod.json (added later in ConfigurationBuilder)
189+
{
190+
"feature_management": {
191+
"feature_flags": [
192+
{ "id": "FeatureB", "enabled": true }
193+
]
194+
}
195+
}
196+
```
197+
198+
With custom merging enabled, `FeatureA` remains enabled and `FeatureB` resolves to enabled (last declaration wins). With default .NET merging (custom merging disabled), arrays are merged by index, which can yield unexpected results if sources don’t align by position.
199+
143200
### .NET Feature Management schema
144201

145202
In previous versions, the primary schema for the feature management library was the [`.NET feature management schema`](https://github.com/microsoft/FeatureManagement-Dotnet/blob/main/schemas/FeatureManagement.Dotnet.v1.0.0.schema.json). Starting from v4.0.0, new features including variants and telemetry are not supported for the .NET feature management schema.

articles/azure-app-configuration/feature-management-overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Feature Flag Telemetry | [GA](./feature-management-dotnet-reference.md#telemetry
5252
Application Insights Integration | [GA](./feature-management-dotnet-reference.md#application-insights-telemetry) | GA | [GA](./feature-management-python-reference.md#application-insights-telemetry) | [GA](./feature-management-javascript-reference.md#application-insights-integration) | WIP
5353
Feature Gate | [GA](./feature-management-dotnet-reference.md#controllers-and-actions) | GA | N/A | N/A | N/A
5454
Feature Gated Middleware | [GA](./feature-management-dotnet-reference.md#application-building) | GA | N/A | N/A | N/A
55+
Custom Feature Flag Configuration Merging | [GA](./feature-management-dotnet-reference.md#handling-multiple-configuration-sources) | N/A | N/A | N/A | N/A
5556

5657
## Support policy
5758

0 commit comments

Comments
 (0)