Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ The feature management library supports appsettings.json as a feature flag sourc

The `FeatureManagement` section of the json document is used by convention to load feature flag settings. In the section above, we see that we have provided three different features. Features define their feature filters using the `EnabledFor` property. In the feature filters for `FeatureT` we see `AlwaysOn`. This feature filter is built-in and if specified will always enable the feature. The `AlwaysOn` feature filter does not require any configuration, so it only has the `Name` property. `FeatureU` has no filters in its `EnabledFor` property and thus will never be enabled. Any functionality that relies on this feature being enabled will not be accessible as long as the feature filters remain empty. However, as soon as a feature filter is added that enables the feature it can begin working. `FeatureV` specifies a feature filter named `TimeWindow`. This is an example of a configurable feature filter. We can see in the example that the filter has a `Parameters` property. This is used to configure the filter. In this case, the start and end times for the feature to be active are configured.

The detailed schema of the `FeatureManagement` section can be found [here](./schemas/FeatureManagement.Dotnet.v1.0.0.schema.json).

**Advanced:** The usage of colon ':' in feature flag names is forbidden.

#### On/Off Declaration
Expand Down Expand Up @@ -144,6 +146,12 @@ A `RequirementType` of `All` changes the traversal. First, if there are no filte

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

#### Microsoft Feature Flag Schema

The feature management library also supports the usage of [`Microsoft Feature Flag schema``](https://github.com/Azure/AppConfiguration/blob/main/docs/FeatureManagement/FeatureFlag.v1.1.0.schema.json) to declare feature flags.
Comment thread
zhiyuanliang-ms marked this conversation as resolved.
Outdated

If you want to use the `Microsoft Feature Flag schema`, you will need to follow [this schema](./schemas/FeatureManagement.Dotnet.v2.0.0.schema.json) to set up the `FeatureManagement` section of the configuration.

Comment thread
zhiyuanliang-ms marked this conversation as resolved.
## Consumption

The basic form of feature management is checking if a feature flag is enabled and then performing actions based on the result. This is done through the `IFeatureManager`'s `IsEnabledAsync` method.
Expand Down
91 changes: 91 additions & 0 deletions schemas/FeatureManagement.Dotnet.v1.0.0.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": ".NET Feature Management Configuration",
"required": [],
"patternProperties": {
"^[^:]*$": {
"description": "Declares a feature flag.",
"oneOf": [
{
"type": "boolean"
},
{
"type": "object",
"required": [
Comment thread
zhiyuanliang-ms marked this conversation as resolved.
"EnabledFor"
],
"properties": {
"RequirementType": {
"type": "string",
"title": "Requirement Type",
"description": "Determines whether any or all registered feature filters must be enabled for the feature to be considered enabled.",
"enum": [
Comment thread
zhiyuanliang-ms marked this conversation as resolved.
"Any",
"All"
],
"default": "Any"
},
"EnabledFor": {
"type": "array",
"title": "Feature Filter Collection",
"description": "Feature Filters that must be evaluated as true for the feature to be considered enabled.",
"items": {
"type": "object",
"title": "Feature Filter Declaration",
"required": [
"Name"
],
"properties": {
"Name": {
"type": "string",
"title": "Feature Filter Name",
"description": "The name used to refer to and require a feature filter.",
"default": "",
"examples": [
"Percentage",
"TimeWindow"
],
"pattern": "^[^:]*$"
},
"Parameters": {
"type": "object",
"title": "Feature Filter Parameters",
"description": "Custom parameters for a given feature filter. A feature filter can require any set of parameters of any type.",
"required": [],
"patternProperties": {
"^.*$": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
},
{
"type": "object"
},
{
"type": "number"
},
{
"type": "array"
},
{
"type": "boolean"
}
]
}
}
}
}
}
},
"additionalProperties": false
}
}
]
}
}
}
19 changes: 19 additions & 0 deletions schemas/FeatureManagement.Dotnet.v2.0.0.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
Comment thread
zhiyuanliang-ms marked this conversation as resolved.
Outdated
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": ".NET Feature Management Configuration",
"required": [
"FeatureFlags"
],
"properties": {
"FeatureFlags": {
"type": "array",
"title": "Feature Flags",
"description": "Declares feature flags based on Microsoft Feature Flag schema v1.1.0.",
"items": {
"$ref": "https://github.com/Azure/AppConfiguration/blob/main/docs/FeatureManagement/FeatureFlag.v1.1.0.schema.json"
}
}
}
}