{"id":6316,"library":"azure-appconfiguration-provider","title":"Azure App Configuration Provider Library for Python","description":"The `azure-appconfiguration-provider` is a Python library that enables applications to centralize and dynamically manage configuration settings using Azure App Configuration. It provides a dictionary-like interface for accessing settings, supports features like dynamic refresh, feature flags, and automatic resolution of Key Vault references. This library, currently at version 2.4.0, is actively maintained within the Azure SDK for Python, with frequent updates addressing features and bug fixes.","status":"active","version":"2.4.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration-provider","tags":["azure","app configuration","cloud","configuration management","microsoft"],"install":[{"cmd":"pip install azure-appconfiguration-provider","lang":"bash","label":"Core library"},{"cmd":"pip install azure-identity","lang":"bash","label":"For Azure Active Directory (recommended)"}],"dependencies":[{"reason":"Required Python version","package":"python","version":">=3.6","optional":false},{"reason":"Recommended for Azure Active Directory authentication, which is the preferred method for connecting to Azure services.","package":"azure-identity","optional":true}],"imports":[{"note":"In version 2.0.0, the `load_provider` class method was replaced by the module-level `load` function for loading configurations.","wrong":"from azure.appconfiguration.provider.AzureAppConfigurationProvider import load_provider","symbol":"load","correct":"from azure.appconfiguration.provider import load"},{"note":"Used to select specific key-value pairs based on key and label filters.","symbol":"SettingSelector","correct":"from azure.appconfiguration.provider import SettingSelector"},{"note":"Used to specify a key to monitor for changes, triggering dynamic refresh.","symbol":"WatchKey","correct":"from azure.appconfiguration.provider import WatchKey"},{"note":"Standard Azure SDK credential for authenticating with Azure Active Directory.","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.appconfiguration.provider import load, SettingSelector\nfrom azure.identity import DefaultAzureCredential\n\n# Set your App Configuration endpoint as an environment variable, e.g., AZURE_APPCONFIG_ENDPOINT\nendpoint = os.environ.get(\"AZURE_APPCONFIG_ENDPOINT\", \"\")\n\nif not endpoint:\n    print(\"Please set the AZURE_APPCONFIG_ENDPOINT environment variable.\")\n    exit(1)\n\ntry:\n    # Authenticate with Azure Active Directory (recommended)\n    # Ensure your principal (user/service principal) has 'App Configuration Data Reader' role.\n    credential = DefaultAzureCredential()\n    \n    # Load configuration from Azure App Configuration\n    # By default, loads all configurations with no label.\n    config = load(\n        endpoint=endpoint,\n        credential=credential,\n        # Example: Load 'TestApp:Settings:Message' and 'TestApp:Settings:FeatureX' with label 'prod'\n        # and all configs with no label, with 'prod' taking precedence.\n        selectors=[\n            SettingSelector(key_filter=\"TestApp:Settings:*\", label_filter=\"prod\"),\n            SettingSelector(key_filter=\"*\", label_filter=\"\\0\") # '\\0' represents no label\n        ],\n        # Enable feature flags loading\n        feature_flags_enabled=True\n    )\n\n    print(f\"Loaded configuration: \")\n    for key, value in config.items():\n        print(f\"  {key}: {value}\")\n\n    # Access configuration values like a dictionary\n    message = config.get(\"TestApp:Settings:Message\", \"Default message\")\n    print(f\"\\nMessage from App Configuration: {message}\")\n    \n    # Check a feature flag\n    if config.get(\"TestApp:Settings:FeatureX\", False):\n        print(\"FeatureX is enabled.\")\n    else:\n        print(\"FeatureX is disabled.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to connect to Azure App Configuration using Azure Active Directory, load configurations (including using `SettingSelector` for filtering), and access values like a dictionary. It also shows how to enable and check feature flags. Ensure `AZURE_APPCONFIG_ENDPOINT` is set as an environment variable and the executing principal has 'App Configuration Data Reader' role."},"warnings":[{"fix":"Update imports and function calls from `from azure.appconfiguration.provider.AzureAppConfigurationProvider import AzureAppConfigurationProvider` and `AzureAppConfigurationProvider.load_provider(...)` to `from azure.appconfiguration.provider import load` and `load(...)` respectively.","message":"The `load_provider` class method was replaced by a module-level `load` function in version 2.0.0. Code using `AzureAppConfigurationProvider.load_provider(...)` will break.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Adjust `AzureAppConfigurationKeyVaultOptions` initialization to use `client_configs` instead of `secret_clients` when resolving Key Vault references.","message":"In version 2.0.0, the handling of `AzureAppConfigurationKeyVaultOptions` changed. The `secret_clients` parameter was removed, and `client_configs` should be used instead, mapping endpoints to client configurations.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Implement periodic calls to `config.refresh()` in your application loop or background task, and specify a `WatchKey` in the `refresh_on` parameter during `load()` to trigger refreshes based on changes to a sentinel key.","message":"Dynamic refresh of configurations requires both setting `refresh_on` (with `WatchKey`) and explicitly calling the `config.refresh()` method. Simply setting `refresh_interval` without `refresh_on` or calling `refresh()` will not update configurations.","severity":"gotcha","affected_versions":"All versions with dynamic refresh support (>=1.1.0b1)."},{"fix":"If dynamic refresh is desired for both, configure `refresh_on` keys to monitor changes relevant to both types of settings, or implement separate logic if their refresh triggers differ.","message":"Refreshing feature flags and regular configuration settings are independent. Enabling `feature_flags_enabled` allows feature flag refresh, but a change in a feature flag will not automatically trigger a refresh of other configuration settings, and vice-versa.","severity":"gotcha","affected_versions":"All versions with dynamic refresh support (>=1.1.0b1)."},{"fix":"When calling `load()`, ensure to provide appropriate `keyvault_credential` (e.g., another `DefaultAzureCredential` instance) that has 'Secrets Reader' permissions on the linked Key Vault.","message":"Resolving Key Vault references requires providing separate Azure Active Directory credentials that have access to the Key Vault. The credentials used to access App Configuration are not automatically used for Key Vault.","severity":"gotcha","affected_versions":"All versions with Key Vault reference support."},{"fix":"Carefully order your `SettingSelector` list, placing selectors for higher-priority configurations (e.g., environment-specific overrides) later in the list.","message":"When using multiple `SettingSelector` objects, the order in which they are provided to the `selectors` parameter matters. Later selectors in the list will override values from earlier selectors if duplicate keys are found.","severity":"gotcha","affected_versions":"All versions with `SettingSelector` support."}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}