Skip to content
AI-200 Learn

Decide what to store in App Configuration vs Key Vault

When a setting belongs in App Configuration or Key Vault: sensitivity test, audit and rotation needs, the reference pattern and common anti-patterns.

What this covers

Both services hold values that steer an application, but they're built for different data. Exam scenarios often describe a setting and ask where it should live. This page gives the decision test, compares the two services side by side and shows the recommended combined architecture.

Exam weight: Secure, monitor, and troubleshoot Azure solutions (20–25%)

Skills measured

  • "Store and retrieve app configuration information by using Azure App Configuration"
  • "Secure secrets by using Azure Key Vault, including rotation and retrieval"

Key concepts

The one-question test

Could this value, on its own, let someone reach a resource or do something they shouldn't?

  • Yes → Key Vault (as a secret, key or certificate).
  • No → App Configuration (as a key-value or feature flag).
App Configuration (non-sensitive)Key Vault (sensitive)
Model endpoint URLs (https://my-openai.openai.azure.com/)Azure OpenAI API keys
Deployment names (gpt-4o, text-embedding-3-large)Connection strings with embedded keys or passwords
Embedding dimensions (1536, 3072)Storage account access keys
Batch sizes, retry counts, timeoutsThird-party tokens and API keys
Feature flagsTLS certificates and private keys
Log levels, diagnostic settingsEncryption keys for data at rest
Queue, container and database namesPasswords and service principal secrets

What each service is designed for

CapabilityApp ConfigurationKey Vault
Labels for environmentsYesNo (use separate vaults)
Feature flagsYesNo
Snapshots and point-in-time restoreYesVersions per secret
Dynamic refresh in the providerYesVia your own cache or secret_refresh_interval
HSM-backed protectionNoPremium tier and Managed HSM
Expiry dates and near-expiry eventsNoYes
Key rotation policiesNoYes (keys)
Soft delete and purge protectionYes (Standard and above)Yes, always on
Access granularityStore-level rolesVault or individual object; per-access audit logs
ThroughputHigher; built for frequent readsStricter throttling (per vault per 10 s)
Value sizeKey + value ≤ 10 KBSecret ≤ 25 KB

Rotation and audit

If a value has to rotate on a schedule, expire, and leave a record of who read it, it belongs in Key Vault. Key Vault diagnostic logs (AuditEvent) record every secret read with the caller identity. Changing a batch size or switching a deployment name is an operational change, not a security event, so App Configuration's labels, revision history and refresh fit better.

The complementary pattern

Use App Configuration as the single entry point and Key Vault as the secure back end:

  • Plain settings and feature flags live in App Configuration.
  • Secrets live in Key Vault and appear in App Configuration as Key Vault references.
  • The app calls load() once and gets one dictionary.
  • Certificates used for TLS are usually read straight from Key Vault (or bound by the hosting platform), not through App Configuration.
Setting typeWhereExample
Non-sensitive configurationApp Configuration valueOpenAI:Endpoint, Pipeline:BatchSize
Feature togglesApp Configuration feature flagUseNewEmbeddingsModel, EnableBatchProcessing
API keys and tokensKey Vault via App Configuration referenceOpenAI:ApiKey, ThirdParty:ServiceToken
Connection strings with credentialsKey Vault via App Configuration referenceCosmosDB:ConnectionString, Storage:AccountKey
CertificatesKey Vault, directTLS certificates for HTTPS endpoints

Better still: no secret at all

Where the target service supports Microsoft Entra ID (Azure OpenAI, Cosmos DB, Storage, Service Bus, App Configuration itself), give the app's managed identity a data role and drop the key entirely. Key Vault is for the credentials you can't eliminate.

How it works

Diagram source: flowchart LR App[AI app] -->|load| AC[App Configuration] AC --> V[Plain values] AC --> FF[Feature flags] AC --> R[Key Vault references] R -->|resolved by app identity| KV[Key Vault] App -->|certificates, direct| KV

Hands-on

Azure portal

  1. In App Configuration, create OpenAI:Endpoint and Pipeline:BatchSize as plain key-values.
  2. Create a feature flag EnableBatchProcessing.
  3. In Key Vault, store openai-api-key; back in App Configuration create a Key Vault reference OpenAI:ApiKey pointing to it.
  4. In the vault's Diagnostic settings, send AuditEvent logs to a Log Analytics workspace so secret reads are audited.

Azure CLI

Azure CLI / Bash
az appconfig kv set --name <store-name> --key "OpenAI:Endpoint" \
  --value "https://<resource>.openai.azure.com/" --yes
az appconfig feature set --name <store-name> --feature EnableBatchProcessing --yes

az keyvault secret set --vault-name <vault-name> --name openai-api-key --value "<api-key>"
az appconfig kv set-keyvault --name <store-name> --key "OpenAI:ApiKey" \
  --secret-identifier "https://<vault-name>.vault.azure.net/secrets/openai-api-key" --yes

az monitor diagnostic-settings create --name kv-audit \
  --resource $(az keyvault show --name <vault-name> --query id -o tsv) \
  --workspace <log-analytics-workspace-id> \
  --logs '[{"category":"AuditEvent","enabled":true}]'

Python

Python
import os
from azure.appconfiguration.provider import load
from azure.identity import DefaultAzureCredential
from featuremanagement import FeatureManager

credential = DefaultAzureCredential()
config = load(
    endpoint=os.environ["AZURE_APPCONFIG_ENDPOINT"],
    credential=credential,
    keyvault_credential=credential,
    feature_flag_enabled=True,
)

settings = {
    "endpoint": config["OpenAI:Endpoint"],         # App Configuration value
    "api_key": config["OpenAI:ApiKey"],            # Key Vault via reference
    "batch_size": int(config["Pipeline:BatchSize"]),
}
batching_on = FeatureManager(config).is_enabled("EnableBatchProcessing")

Exam traps

ScenarioCorrect placement
Model deployment name changes after validationApp Configuration
Cosmos DB connection string with account keyKey Vault, referenced from App Configuration
Per-environment retry countsApp Configuration with labels
Credential needing 90-day rotation and auditKey Vault
TLS certificate for an HTTPS endpointKey Vault
Emergency off switch for a pipeline stageApp Configuration feature flag

Quick review

  • Values that grant access go to Key Vault; values that tune behavior go to App Configuration.
  • Key Vault adds expiry, rotation, per-access audit and HSM protection.
  • App Configuration adds labels, feature flags, snapshots and dynamic refresh.
  • Recommended pattern: App Configuration as the entry point, Key Vault references for secrets.
  • Certificates are read directly from Key Vault.
  • Avoid duplicating values across services; avoid hard-coding.
  • Prefer managed identity to eliminate secrets where the target supports Entra ID.

Practice

Practice: Azure App Configuration questions

Practice: Azure Key Vault questions

Official references