Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 26 of 28
❮Prev Next❯

Azure App Configuration: Settings and Feature Flags

Module 4: Secure & Monitor ⏱ 10 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    Azure App Configuration is a central store for app settings. Each setting is a key-value with an optional label (such as prod) and a content type. Feature flags live under the .appconfig.featureflag/ prefix, and Key Vault references point at secrets without storing them. In Python, load() from azure-appconfiguration-provider reads the keys you select, trims prefixes, resolves Key Vault references with a keyvault_credential, and refreshes when a sentinel key changes.

    Simulate it » No Azure account needed

    Exam objective: 4.1.2 Store and retrieve app configuration information by using Azure App Configuration. (Skills measured as of October 7, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Key-values, labels, a Key Vault reference and a feature flag Add key-values with labels and a feature flag.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Open <strong>Operations → Configuration explorer</strong> and select <strong>+ Create → Key-value</strong>.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Open Operations → Configuration explorer and select + Create → Key-value.
    2. A label lets one key hold different values per environment. Your app asks for the prod label in production.
    3. Same key, two labels. Now add a secret, but by reference: + Create → Key Vault reference.
    4. App Configuration stores only the secret URI. Your app’s identity reads the value from Key Vault.
    5. Open Feature manager and select + Create.
    6. Turn the semantic cache on for 20% of users first with a targeting filter.
    7. Something wrong? Toggle it Off here and every app instance stops using it within the refresh interval.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    Switching to a new model means a full redeploy of six services.

    😊 THE SOLUTION

    Keep settings and feature flags in App Configuration and refresh them live.

    • Redeploy to change a value✓ Dynamic refresh
    • Different values per environment✓ Labels
    • Risky roll-outs✓ Feature flags
    🛠️ Solved with: Azure App Configuration

    Start with a question

    You want to switch the chatbot to a newer model. Why does that need six redeploys?

    Because the deployment name is typed into six services’ config files. Change it, rebuild six images, roll out six releases, and hope nobody missed one. Then, if the new model misbehaves, do it all again backwards.

    Settings that many services share shouldn’t live inside each service. Azure App Configuration keeps them in one store. Change a value once, flip a feature flag for the new model, and every app reloads it in the next minute or so, without a restart.

    Explain it like I’m 10

    The technical explanation

    What’s in a store

    Each entry is a key-value:

    PartExampleNotes
    KeyChatApp:Model:DeploymentAny string. : or / are common separators for a hierarchy.
    LabelprodOptional. Same key, different value per label. No label is the “null label”.
    Valuegpt-4.1A string, up to the store’s size limit.
    Content typeapplication/jsonOptional. Tells the provider how to read the value.

    Two special kinds of key-value:

    • Feature flags use keys under .appconfig.featureflag/ (for example .appconfig.featureflag/use-gpt-5) with the content type application/vnd.microsoft.appconfig.ff+json;charset=utf-8. The value is JSON with enabled and optional filters (targeting a group, a percentage of users, a time window).
    • Key Vault references have the content type application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8 and a value like {"uri":"https://kv-tailspin.vault.azure.net/secrets/cosmos-key"}. App Configuration stores only the URI.
    az appconfig kv set -n appcs-tailspin --key ChatApp:Model:Deployment --value gpt-4.1 --label prod
    az appconfig kv set-keyvault -n appcs-tailspin --key ChatApp:Cosmos:Key \
      --secret-identifier https://kv-tailspin.vault.azure.net/secrets/cosmos-key --label prod
    az appconfig feature set -n appcs-tailspin --feature use-gpt-5 --label prod

    Access

    Use Microsoft Entra ID, not access keys. The app’s managed identity gets App Configuration Data Reader on the store (Data Owner can also write). If the store has Key Vault references, the same identity needs Key Vault Secrets User on the vault, because the provider in your app fetches the secret, not App Configuration.

    Load settings in Python

    pip install azure-appconfiguration-provider azure-identity featuremanagement
    import os
    from azure.identity import DefaultAzureCredential
    from azure.appconfiguration.provider import load, SettingSelector, WatchKey
    from featuremanagement import FeatureManager
    
    credential = DefaultAzureCredential()
    
    config = load(
        endpoint=os.environ["APP_CONFIG_ENDPOINT"],          # https://appcs-tailspin.azconfig.io
        credential=credential,
        selects=[
            SettingSelector(key_filter="ChatApp:*"),                     # no-label defaults first
            SettingSelector(key_filter="ChatApp:*", label_filter="prod") # prod values win
        ],
        trim_prefixes=["ChatApp:"],                         # "ChatApp:Model:Deployment" -> "Model:Deployment"
        keyvault_credential=credential,                     # resolves Key Vault references
        refresh_on=[WatchKey("ChatApp:Sentinel", label="prod")],
        refresh_interval=60,                                # seconds between sentinel checks
        feature_flag_enabled=True,
    )
    
    deployment = config["Model:Deployment"]   # behaves like a read-only dict
    cosmos_key = config["Cosmos:Key"]         # already the secret value from Key Vault
    
    features = FeatureManager(config)
    
    def handle_request(question: str):
        config.refresh()                      # cheap: checks the sentinel only when the interval has passed
        model = "gpt-5" if features.is_enabled("use-gpt-5") else config["Model:Deployment"]
        ...

    A few details that catch people:

    • Order of selectors matters. Later selectors override earlier ones for the same key, so put the null-label defaults first and the environment label after.
    • refresh() is yours to call. refresh_on and refresh_interval only say what to watch and how often to check. If you never call config.refresh(), nothing reloads.
    • The sentinel goes last. Change the five settings you need, then update ChatApp:Sentinel. The app sees the sentinel change and reloads all of them together, so it never runs with half old, half new values.
    1. 1 Edit

      You change several key-values in the store.

    2. 2 Sentinel

      You update ChatApp:Sentinel last.

    3. 3 Check

      config.refresh() runs; the interval has passed, so it reads the sentinel.

    4. 4 Reload

      The sentinel changed, so every selected key is loaded again.

    Dynamic refresh with a sentinel key

    Snapshots

    A snapshot is a named, read-only set of key-values captured from filters at one moment, for example release-2026-11. Load it with SettingSelector(snapshot_name="release-2026-11"). Because it can’t change, production runs exactly what you tested, and rollback means loading the previous snapshot.

    Architect level App Configuration or Key Vault?

    They do different jobs and usually work together. Key Vault is for values that would hurt if leaked; it has hardware-backed keys, rotation events and tight per-secret access. App Configuration is for everything else your app reads: deployment names, timeouts, prompt templates, feature flags. It has labels, snapshots, change history and fast refresh. Putting plain settings in Key Vault makes them awkward to change and costs more operations; putting secrets in App Configuration means anyone with Data Reader can read them. The Key Vault reference joins the two: one config source in code, secrets still guarded by Key Vault.

    Real-world business scenario

    Education technology

    Contoso Learning (fictional)

    The problem
    Six services in Container Apps each had the model deployment name and prompt settings in environment variables. Every model change took a day of redeploys, and dev settings once leaked into production.
    What they used
    One App Configuration store with dev and prod labels, a use-gpt-5 feature flag with a targeting filter for teachers, Key Vault references for the Cosmos DB key, and the Python provider refreshing on a sentinel key every 60 seconds.
    Why that choice
    Settings changed in one place reach every service in about a minute, labels keep environments apart, and the secrets themselves stay in Key Vault.
    The result
    The team switched teachers to the new model on a Tuesday afternoon, watched the results, and rolled it out to students on Thursday without a single deployment.

    When to use it and when not to

    ✓ Use it when…

    • Several services share settings such as model deployment names or endpoints.
    • You want feature flags to roll out a new model or prompt gradually.
    • You need different values per environment, change history or immutable release snapshots.

    ✕ Think twice when…

    • Storing secret values directly. Keep them in Key Vault and add a reference.
    • A single small app with a couple of settings that never change. App settings are enough.

    ↔ Alternatives to consider

    • Azure Key Vault for the secrets themselves.
    • App settings in App Service or Container Apps for values that belong to one app only.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AI-200 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    Several services read the setting ChatApp:Model:Deployment from Azure App Configuration. The setting must have one value in the development environment and a different value in production, and the key name must stay the same. What should you use?

    Question 2

    Question 2 of 5

    An application loads its settings from Azure App Configuration. One setting must contain a database password, and the password must remain stored only in Azure Key Vault. What should you add to the App Configuration store?

    Question 3

    Question 3 of 5

    A Python app calls load() from the azure-appconfiguration-provider package with refresh_on=[WatchKey("ChatApp:Sentinel")] and refresh_interval=60. An administrator changes three key-values and then updates ChatApp:Sentinel. The app never shows the new values.

    What is the most likely cause?

    Question 4

    Question 4 of 5 · Select 2

    An app uses its managed identity to load settings from Azure App Configuration. Some settings are Key Vault references. Which TWO role assignments does the managed identity require? Each correct answer presents part of the solution.

    Question 5

    Question 5 of 5

    You plan to release a new version of an AI service. Production must load exactly the set of key-values that was tested, and the set must not change after the release, even if someone edits the store. What should you use?

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner Why use App Configuration when App Service already has app settings?

    Model answer

    App settings belong to one app. When six services share the same model deployment name and endpoint, I'd rather change it once. App Configuration gives me one store with labels for each environment, feature flags and a change history, and apps can refresh without restarting.

    Intermediate Should you store an API key in App Configuration?

    Model answer

    No. I store the key in Key Vault and add a Key Vault reference in App Configuration. The reference holds only the secret's URI. The app's provider reads the URI and fetches the secret from Key Vault using its own identity, so App Configuration never sees the value.

    Interviewer follows up

    What permissions does the app need then?

    You

    App Configuration Data Reader on the store, and Key Vault Secrets User on the vault, because the app itself reads the secret.

    Experienced developer How do you make a Python app pick up a changed setting without a restart?

    Model answer

    I pass refresh_on with a WatchKey for a sentinel key and a refresh_interval to load(), then call config.refresh() regularly, for example once per request or in a background loop. When the interval has passed, the provider checks the sentinel. If it changed, it reloads every selected key.

    Scenario You want to try a new model with internal users first, then everyone. How?

    Model answer

    A feature flag in App Configuration, say use-gpt-5, with a targeting filter for the internal group. The code checks feature_manager.is_enabled("use-gpt-5") and picks the deployment. When I'm happy, I widen the audience or switch the flag on for everyone. No redeploy either way.

    Architecture & design How would you make a release's configuration repeatable and easy to roll back?

    Model answer

    I'd create a snapshot of the release's key-values, for example release-2026-11, and have production load that snapshot by name. A snapshot can't change, so production sees exactly what was tested. Rolling back means pointing at the previous snapshot.

    Quick revision

    Key points

    • Settings are key-values with optional labels and content types.
    • Feature flags are key-values under .appconfig.featureflag/.
    • Key Vault references store a secret URI. The app's provider fetches the secret with its own identity.
    • load(endpoint, credential, selects, trim_prefixes, refresh_on, refresh_interval, keyvault_credential) builds a dict-like config.
    • Dynamic refresh needs refresh_on (a sentinel key) plus calling config.refresh().
    • Apps need App Configuration Data Reader; Data Owner can write.

    Important terminology

    Azure App Configuration
    A managed service that stores application settings and feature flags centrally for many apps and environments.
    Key-value
    One setting in App Configuration, made of a key, a value, an optional label and an optional content type.
    Label
    An extra attribute on a key-value that lets the same key hold different values, usually one per environment.
    Feature flag
    An on or off switch, stored as a key-value with the .appconfig.featureflag/ prefix, that turns code paths on without a redeploy.
    Key Vault reference
    A key-value whose value is the URI of a Key Vault secret. The app's provider fetches the secret from Key Vault.
    Sentinel key
    One key you update last after a batch of changes. The app watches it and reloads all settings when it changes.
    Snapshot
    A named, read-only copy of a set of key-values at one moment, used for safe releases and rollbacks.

    Common mistakes

    • Putting secret values straight into App Configuration instead of Key Vault references.
    • Setting refresh_on but never calling refresh(), so nothing changes.
    • Forgetting Key Vault Secrets User for the app, so Key Vault references fail to resolve.

    Exam tips

    • "Same key, different value per environment" = labels.
    • "Turn a feature on without redeploying" = feature flag.
    • "Reload all settings only after a batch of changes" = sentinel key with refresh_on.
    • "Immutable set of settings for a release" = snapshot.

    Five quick revision questions

    1. 1.Which prefix do feature flag keys use?Show

      .appconfig.featureflag/

    2. 2.Which Python package provides load()?Show

      azure-appconfiguration-provider.

    3. 3.Which load() argument strips a prefix from key names?Show

      trim_prefixes.

    4. 4.Which role lets an app read key-values?Show

      App Configuration Data Reader.

    5. 5.Where does the secret value of a Key Vault reference live?Show

      In Key Vault. App Configuration stores only its URI.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Distributed Tracing with OpenTelemetry

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.