Microsoft Feature Management
raw JSON → 2.1.0 verified Mon Apr 27 auth: no python
A Python library for enabling/disabling features at runtime, commonly used in .NET-style feature flag systems. Current version: 2.1.0. Released as needed, follows semantic versioning.
pip install featuremanagement Common errors
error ModuleNotFoundError: No module named 'featuremanagement' ↓
cause The library is not installed or the Python environment is incorrect.
fix
Run 'pip install featuremanagement' in the correct environment.
error AttributeError: 'FeatureManager' object has no attribute 'is_enabled' ↓
cause Typo or older version without 'is_enabled' method.
fix
Use FeatureManager from featuremanagement 2.0+, which includes 'is_enabled'. Check your installed version with 'pip show featuremanagement'.
error ValueError: The feature flag configuration is invalid. ↓
cause The flags dictionary passed to FeatureManager does not conform to the required schema.
fix
Ensure each flag has an 'enabled' key with a boolean value. Optionally add 'conditions' with appropriate filters.
Warnings
gotcha Feature flags dictionary must follow the correct schema: each flag must have an 'enabled' key (boolean) and optionally 'conditions'. ↓
fix Ensure your flag dictionary structure matches: {"FeatureName": {"enabled": True}}.
gotcha The library expects feature flags in a specific format when using Azure App Configuration; mismatched structure can cause silent failures. ↓
fix Use the Azure App Configuration provider to load flags automatically, or manually parse flags to match the expected schema.
deprecated The method 'is_enabled' is stable but some older documentation refers to 'is_enabled' with a different signature (without the user context). ↓
fix Ensure you pass the correct arguments: is_enabled(feature_name, user_context=None).
Imports
- FeatureManager
from featuremanagement import FeatureManager - FeatureFilterEvaluationContext
from featuremanagement import FeatureFilterEvaluationContext
Quickstart
from featuremanagement import FeatureManager
# Initialize with in-memory feature flags
feature_manager = FeatureManager(feature_flags={
"Beta": {
"enabled": True
}
})
# Check if a feature is enabled
if feature_manager.is_enabled("Beta"):
print("Beta feature is enabled")
else:
print("Beta feature is disabled")