{"id":1345,"library":"azure-appconfiguration","title":"Azure App Configuration Client","description":"The Microsoft App Configuration Data Client Library for Python provides functionality to manage application settings and feature flags in Azure App Configuration. It is currently at version 1.8.0 and follows the Azure SDK's regular release cadence, with updates typically several times a year.","status":"active","version":"1.8.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration","tags":["azure","configuration","cloud","settings","feature-flags"],"install":[{"cmd":"pip install azure-appconfiguration azure-identity","lang":"bash","label":"Install with authentication library"}],"dependencies":[{"reason":"Commonly used for authenticating with Azure services.","package":"azure-identity","optional":false}],"imports":[{"symbol":"AzureAppConfigurationClient","correct":"from azure.appconfiguration import AzureAppConfigurationClient"},{"symbol":"ConfigurationSetting","correct":"from azure.appconfiguration import ConfigurationSetting"},{"note":"Required for authenticating with Azure services.","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.appconfiguration import AzureAppConfigurationClient\nfrom azure.identity import DefaultAzureCredential\n\n# It is recommended to set environment variables for your App Configuration endpoint and credentials.\n# For example:\n# AZURE_APPCONFIGURATION_ENDPOINT=\"https://<your-app-config-name>.azconfig.io\"\n# AZURE_CLIENT_ID=\"<your-client-id>\"\n# AZURE_CLIENT_SECRET=\"<your-client-secret>\"\n# AZURE_TENANT_ID=\"<your-tenant-id>\" (if using service principal)\n\napp_config_endpoint = os.environ.get('AZURE_APPCONFIGURATION_ENDPOINT', 'https://YOUR_APP_CONFIG_ENDPOINT.azconfig.io')\n# The key of the setting you want to retrieve\nconfig_key = \"MyApplication:Settings:MyKey\"\n\ntry:\n    # DefaultAzureCredential attempts to authenticate via various methods:\n    # Environment variables, Managed Identity, Azure CLI, Visual Studio Code, etc.\n    credential = DefaultAzureCredential()\n\n    # Create a synchronous client\n    client = AzureAppConfigurationClient(endpoint=app_config_endpoint, credential=credential)\n\n    # Retrieve a configuration setting.\n    # By default, get_configuration_setting retrieves settings with no label.\n    # If your setting has a label, you must specify it, e.g., label=\"development\"\n    setting = client.get_configuration_setting(key=config_key)\n\n    if setting:\n        print(f\"Successfully retrieved setting:\")\n        print(f\"  Key: {setting.key}\")\n        print(f\"  Value: {setting.value}\")\n        print(f\"  Label: {setting.label if setting.label else 'None'}\")\n        print(f\"  Content Type: {setting.content_type if setting.content_type else 'None'}\")\n    else:\n        print(f\"Setting with key '{config_key}' not found or no label matched.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure 'AZURE_APPCONFIGURATION_ENDPOINT' is set and valid.\")\n    print(f\"Also verify that a setting with key '{config_key}' exists in your Azure App Configuration store and your credentials have 'App Configuration Data Reader' permissions.\")","lang":"python","description":"Connect to an Azure App Configuration store and retrieve a key-value setting using `DefaultAzureCredential` for authentication. Remember to set the `AZURE_APPCONFIGURATION_ENDPOINT` environment variable and ensure the specified key exists."},"warnings":[{"fix":"Verify `az login` status, ensure required environment variables are correctly configured, or use a more specific credential type like `ClientSecretCredential` if `DefaultAzureCredential` is problematic.","message":"Authentication failures are common with `DefaultAzureCredential`. It relies on a specific order of authentication methods (environment variables, managed identity, Azure CLI login, etc.). Ensure your environment variables (e.g., `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID`) are correctly set, or that you are logged in via Azure CLI (`az login`).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always consider if your configuration settings use labels. Explicitly include the `label` parameter in `get_configuration_setting` or `label_filter` in `list_configuration_settings` if your settings are labeled. Use `label=None` or `label_filter=LabelFilter.NULL` to specifically target settings without a label.","message":"App Configuration settings can have optional 'labels'. When retrieving a setting using `get_configuration_setting(key='my_key')`, it only returns settings with a 'null' label by default. If your setting has a label (e.g., 'development'), you must explicitly specify it: `get_configuration_setting(key='my_key', label='development')`. For listing settings, use `label_filter`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Grant the appropriate RBAC roles ('App Configuration Data Reader' or 'App Configuration Data Owner') to the identity used by `DefaultAzureCredential` (e.g., your user account, service principal, or managed identity) on the Azure App Configuration resource.","message":"The client requires appropriate Azure Role-Based Access Control (RBAC) permissions. To read settings, the principal needs 'App Configuration Data Reader' role. To write (set/delete) settings, 'App Configuration Data Owner' is required. Lack of proper roles will result in authorization errors, typically '403 Forbidden'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `AsyncAzureAppConfigurationClient` with `await` in an `async` function for asynchronous operations, or stick to `AzureAppConfigurationClient` for synchronous code. Do not mix them without explicitly managing task execution.","message":"The SDK provides both synchronous (`AzureAppConfigurationClient`) and asynchronous (`AsyncAzureAppConfigurationClient`) clients. Mixing synchronous client calls within an asynchronous context (or vice versa) without proper handling can lead to blocking behavior or runtime errors. Choose the appropriate client for your application's concurrency model.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}