references/examples.md · 24000
iguration config.setSetting("app/database/timeout", "30000"); config.setSetting("app/cache/ttl", "3600");
// Get configuration
String timeout = config.getSetting("app/database/timeout");
System.out.println("Database timeout: " + timeout);
// Feature flags
config.setFeatureEnabled("dark-mode", true);
if (config.isFeatureEnabled("dark-mode")) {
System.out.println("Dark mode is enabled");
}
// Get all app settings
Map<String, String> appSettings = config.getAllSettings("app/");
System.out.println("\n=== All App Settings ===");
appSettings.forEach((key, value) ->
System.out.printf("%s = %s%n", key, value));
// Create a snapshot for release
config.createSnapshot("release-" + System.currentTimeMillis(), "app/");
}
}
## Environment Variables
```bash
AZURE_APPCONFIG_CONNECTION_STRING=Endpoint=https://<store>.azconfig.io;Id=<id>;Secret=<secret>
AZURE_APPCONFIG_ENDPOINT=https://<store>.azconfig.io
# For DefaultAzureCredential
AZURE_CLIENT_ID=<service-principal-client-id>
AZURE_CLIENT_SECRET=<service-principal-secret>
AZURE_TENANT_ID=<tenant-id>
Best Practices
- Use labels — Separate configurations by environment (Dev, Staging, Production)
- Use snapshots — Create immutable snapshots for releases
- Feature flags — Use for gradual rollouts and A/B testing
- Secret references — Store sensitive values in Key Vault, not App Configuration
- Conditional requests — Use ETags for optimistic concurrency
- Read-only protection — Lock critical production settings
- Use Entra ID — Preferred over connection strings for security
- Async client — Use for high-throughput scenarios