Loading Configuration in Python Applications
This lesson explains the App Configuration provider, selectors and label layering, snapshots and other ways to consume configuration.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish the provider from the client SDK.
- Describe selectors, prefix trimming and label layering.
- Explain how snapshots give consistent releases.
- Compare ways to consume configuration on each platform.
The provider and the SDK
Two Python packages talk to App Configuration. The configuration provider, azure-appconfiguration-provider, is designed for applications that consume configuration: it loads many settings in one call, returns a dictionary-like object, resolves Key Vault references, refreshes dynamically and supports feature flags. The client SDK, azure-appconfiguration, offers individual operations such as setting and deleting key-values, which suits tools and pipelines that manage configuration. Applications should normally use the provider.
from azure.appconfiguration.provider import load, SettingSelector
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()
config = load(
endpoint="https://STORE.azconfig.io",
credential=credential,
selects=[SettingSelector(key_filter="OrdersApi:*", label_filter="prod")],
trim_prefixes=["OrdersApi:"],
keyvault_credential=credential)
top_k = int(config["Retrieval:TopK"])
db_password = config["Database:Password"] # resolved from Key VaultThe example loads only keys that start with OrdersApi: and have the label prod, removes the prefix so that code uses short names, and resolves Key Vault references with the same managed identity. Loading only the keys an application needs keeps start-up fast and the request count low.
Provider or SDK?
Selectors and label layering
A SettingSelector combines a key filter and a label filter. Several selectors can be passed, and when the same key is loaded by more than one, later selectors win. This enables layering: load shared defaults first, then environment-specific overrides.
config = load(
endpoint="https://STORE.azconfig.io", credential=credential,
selects=[
SettingSelector(key_filter="Shared:*", label_filter="\0"), # defaults with no label
SettingSelector(key_filter="Shared:*", label_filter="prod"), # production overrides
],
trim_prefixes=["Shared:"])The special label filter \0 selects key-values with no label. With this layering, only values that differ in production need a prod label, and every other key falls back to the shared default.
Layered configuration that never overrides
Snapshots
A snapshot is a named, immutable copy of a set of key-values, chosen with key and label filters at the moment it is created. Applications can load a snapshot instead of live key-values, so that every instance of a release reads exactly the same configuration, even if someone edits the live values. Promoting a release then means pointing it at a new snapshot, and rolling back means pointing it at the previous one.
az appconfig snapshot create --name STORE --snapshot-name orders-api-2026-11-02 \
--filters '{"key":"OrdersApi:*","label":"prod"}'config = load(endpoint="https://STORE.azconfig.io", credential=credential,
selects=[SettingSelector(snapshot_name="orders-api-2026-11-02")])Snapshots are retained for a configurable period after they are archived and count towards the store's snapshot storage.
The following diagram compares live key-values with a snapshot during a rolling deployment.

Other ways to consume configuration
Not every component needs the provider. App Service and Azure Functions can resolve individual values with App Configuration references in app settings, and Azure Kubernetes Service can use the App Configuration Kubernetes Provider, which writes settings into ConfigMaps and Secrets. Container Apps workloads typically use the provider in code. Each approach authenticates with the workload's managed identity.
| Approach | Dynamic refresh | Feature flags | Code changes |
|---|---|---|---|
| Provider library in code | Yes | Yes, with feature management | Small, at start-up |
| App Service and Functions references | Values refreshed by the platform; app restarts | No | None |
| Kubernetes Provider | Yes, updates ConfigMaps | Yes | None if the app reads ConfigMaps |
Consuming configuration
A release with consistent configuration
During a rolling deployment of a retrieval API, an engineer changed Retrieval:ScoreThreshold in production. Half of the instances started with the old value and half with the new one, and answers differed between requests. The team wants each release to run with one fixed set of settings, while still allowing a planned change to be promoted.
The release process should create a snapshot of the API's production key-values and have the application load the snapshot by name, passed in through the deployment. All instances of that release then read identical values, regardless of edits to live key-values. A configuration change is promoted by creating a new snapshot and deploying with its name, and rolled back by returning to the previous snapshot.
Adding a label per release would work only if nobody edits labelled values, which is what went wrong. Copying values into app settings would lose central management. Disabling dynamic refresh would not stop instances from loading different values at start-up.
Two selectors load the same key, one with no label and one with the label prod. Which value does the application get?
Show answer
The value from the later selector. Listing the no-label selector first and the prod selector second makes production values override the defaults.
Exam Tips
Remember for the exam
- Use azure-appconfiguration-provider load() in applications; the SDK client is for management.
- Selectors filter keys and labels; later selectors override earlier ones; \0 means no label.
- trim_prefixes shortens key names; keyvault_credential resolves Key Vault references.
- Snapshots are immutable sets of key-values for consistent releases and rollbacks.