Azure App Configuration SDK for Python
Centralized configuration management with feature flags and dynamic settings.
Installation
pip install azure-appconfiguration
Environment Variables
AZURE_APPCONFIGURATION_CONNECTION_STRING=Endpoint=https://<name>.azconfig.io;Id=...;Secret=...
# Or for Entra ID:
AZURE_APPCONFIGURATION_ENDPOINT=https://<name>.azconfig.io
Authentication
Connection String
from azure.appconfiguration import AzureAppConfigurationClient
client = AzureAppConfigurationClient.from_connection_string(
os.environ["AZURE_APPCONFIGURATION_CONNECTION_STRING"]
)
Entra ID
from azure.appconfiguration import AzureAppConfigurationClient
from azure.identity import DefaultAzureCredential
client = AzureAppConfigurationClient(
base_url=os.environ["AZURE_APPCONFIGURATION_ENDPOINT"],
credential=DefaultAzureCredential()
)
Configuration Settings
Get Setting
setting = client.get_configuration_setting(key="app:settings:message")
print(f"{setting.key} = {setting.value}")
Get with Label
# Labels allow environment-specific values
setting = client.get_configuration_setting(
key="app:settings:message",
label="production"
)
Set Setting
from azure.appconfiguration import ConfigurationSetting
setting = ConfigurationSetting(
key="app:settings:message",
value="Hello, World!",
label="development",
content_type="text/plain",
tags={"environment": "dev"}
)
client.set_configuration_setting(setting)
Delete Setting
client.delete_configuration_setting(
key="app:settings:message",
label="development"
)
List Settings
All Settings
settings = client.list_configuration_settings()
for setting in settings:
print(f"{setting.key} [{setting.label}] = {setting.value}")
Filter by Key Prefix
settings = client.list_configuration_settings(
key_filter="app:settings:*"
)
Filter by Label
settings = client.list_configuration_settings(
label_filter="production"
)
Feature Flags
Set Feature Flag
from azure.appconfiguration import ConfigurationSetting
import json
feature_flag = ConfigurationSetting(
key=".appconfig.featureflag/beta-feature",
value=json.dumps({
"id": "beta-feature",
"enabled": True,
"conditions": {
"client_filters": []
}
}),
content_type="application/vnd.microsoft.appconfig.ff+json;charset=utf-8"
)
client.set_configuration_setting(feature_flag)
Get Feature Flag
setting = client.get_configuration_setting(
key=".appconfig.featureflag/beta-feature"
)
flag_data = json.loads(setting.value)
print(f"Feature enabled: {flag_data['enabled']}")
List Feature Flags
flags = client.list_configuration_settings(
key_filter=".appconfig.featureflag/*"
)
for flag in flags:
data = json.loads(flag.value)
print(f"{data['id']}: {'enabled' if data['enabled'] else 'disabled'}")
Read-Only Settings
# Make setting read-only
client.set_read_only(
configuration_setting=setting,
read_only=True
)
# Remove read-only
client.set_read_only(
configuration_setting=setting,
read_only=False
)
Snapshots
Create Snapshot
from azure.appconfiguration import ConfigurationSnapshot, ConfigurationSettingFilter
snapshot = ConfigurationSnapshot(
name="v1-snapshot",
filters=[
ConfigurationSettingFilter(key="app:*", label="production")
]
)
created = client.begin_create_snapshot(
name="v1-snapshot",
snapshot=snapshot
).result()
List Snapshot Settings
settings = client.list_configuration_settings(
snapshot_name="v1-snapshot"
)
Async Client
from azure.appconfiguration.aio import AzureAppConfigurationClient
from azure.identity.aio import DefaultAzureCredential
async def main():
credential = DefaultAzureCredential()
client = AzureAppConfigurationClient(
base_url=endpoint,
credential=credential
)
setting = await client.get_configuration_setting(key="app:message")
print(setting.value)
await client.close()
await credential.close()
Client Operations
| Operation | Description |
get_configuration_setting | Get single setting |
set_configuration_setting | Create or update setting |
delete_configuration_setting | Delete setting |
list_configuration_settings | List with filters |
set_read_only | Lock/unlock setting |
begin_create_snapshot | Create point-in-time snapshot |
list_snapshots | List all snapshots |
Best Practices
- Use labels for environment separation (dev, staging, prod)
- Use key prefixes for logical grouping (app:database:, app:cache:)
- Make production settings read-only to prevent accidental changes
- Create snapshots before deployments for rollback capability
- Use Entra ID instead of connection strings in production
- Refresh settings periodically in long-running applications
- Use feature flags for gradual rollouts and A/B testing
Skill Information
- Source
- Microsoft
- Category
- Cloud & Azure
- Repository
- View on GitHub
Related Skills
agent-framework-azure-ai-py
Build Azure AI Foundry agents using the Microsoft Agent Framework Python SDK (agent-framework-azure-ai). Use when creating persistent agents with AzureAIAgentsProvider, using hosted tools (code interpreter, file search, web search), integrating MCP servers, managing conversation threads, or implementing streaming responses. Covers function tools, structured outputs, and multi-tool agents.
Microsoftazd-deployment
Deploy containerized applications to Azure Container Apps using Azure Developer CLI (azd). Use when setting up azd projects, writing azure.yaml configuration, creating Bicep infrastructure for Container Apps, configuring remote builds with ACR, implementing idempotent deployments, managing environment variables across local/.azure/Bicep, or troubleshooting azd up failures. Triggers on requests for azd configuration, Container Apps deployment, multi-service deployments, and infrastructure-as-code with Bicep.
Microsoftazure-ai-agents-persistent-dotnet
Azure AI Agents Persistent SDK for .NET. Low-level SDK for creating and managing AI agents with threads, messages, runs, and tools. Use for agent CRUD, conversation threads, streaming responses, function calling, file search, and code interpreter. Triggers: "PersistentAgentsClient", "persistent agents", "agent threads", "agent runs", "streaming agents", "function calling agents .NET".
Microsoftazure-ai-agents-persistent-java
Azure AI Agents Persistent SDK for Java. Low-level SDK for creating and managing AI agents with threads, messages, runs, and tools. Triggers: "PersistentAgentsClient", "persistent agents java", "agent threads java", "agent runs java", "streaming agents java".
Microsoftazure-ai-anomalydetector-java
Build anomaly detection applications with Azure AI Anomaly Detector SDK for Java. Use when implementing univariate/multivariate anomaly detection, time-series analysis, or AI-powered monitoring.
Microsoft