Azure App Configuration Management Client Library for Python
The `azure-mgmt-appconfiguration` library provides a client for managing Azure App Configuration resources. It enables programmatic interaction with App Configuration stores, allowing operations like creating, updating, and deleting configuration stores. This package is part of the larger Azure SDK for Python and is currently at version 5.0.0, with a regular release cadence including both minor updates and major versions that may introduce breaking changes.
Warnings
- breaking Starting from version 4.0.0, the package primarily targets only the latest API version available on Azure and removes APIs of older versions. If your application relies on a specific, non-latest API version, you must pin the package to a previous released version (e.g., `<4.0.0`).
- breaking In version 3.0.0, the operation `KeyValuesOperations.list_by_configuration_store` was removed, impacting users migrating from earlier versions who might have used this specific method.
- breaking For SDK versions 1.0.0b1 and newer, the credential system was completely revamped. Old authentication classes like `azure.common.credentials` or `msrestazure.azure_active_directory` are no longer supported. The `credential` parameter has also been renamed from `credentials`.
- gotcha Storing sensitive information (secrets) directly in Azure App Configuration is not recommended. Instead, use Azure Key Vault to securely store secrets and then reference them from App Configuration. This provides hardware-level encryption and better secret management.
- gotcha When deploying applications to Azure services (like Azure Kubernetes Service, App Service, or Azure Functions), it's highly recommended to use Managed Identities for authenticating with App Configuration. This eliminates the need to explicitly manage connection strings or client secrets in your application or environment variables, enhancing security.
Install
-
pip install azure-mgmt-appconfiguration azure-identity
Imports
- AppConfigurationManagementClient
from azure.mgmt.appconfiguration import AppConfigurationManagementClient
- DefaultAzureCredential
from azure.identity import DefaultAzureCredential
Quickstart
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.appconfiguration import AppConfigurationManagementClient
# Set environment variables for authentication (Azure CLI, VS Code, environment variables)
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET or AZURE_FEDERATED_TOKEN_FILE
# AZURE_SUBSCRIPTION_ID
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "")
if not subscription_id:
raise ValueError("AZURE_SUBSCRIPTION_ID is not set in environment variables.")
# Authenticate using DefaultAzureCredential
# This will try various methods like environment variables, managed identity, etc.
credential = DefaultAzureCredential()
# Create a client for App Configuration Management
client = AppConfigurationManagementClient(credential=credential, subscription_id=subscription_id)
# Example: List all App Configuration stores in the subscription
print("Listing App Configuration stores:")
for store in client.configuration_stores.list():
print(f" - {store.name} (Resource Group: {store.resource_group})")
print("Quickstart complete.")