Build applications using Azure App Configuration SDK for JavaScript (@azure/app-configuration). Use when working with configuration settings, feature flags, Key Vault references, dynamic refresh, or centralized configuration management.
Add this skill
npx mdskills install sickn33/azure-appconfiguration-tsComprehensive SDK reference with extensive examples but lacks agent-specific instructions
1---2name: azure-appconfiguration-ts3description: Build applications using Azure App Configuration SDK for JavaScript (@azure/app-configuration). Use when working with configuration settings, feature flags, Key Vault references, dynamic refresh, or centralized configuration management.4package: "@azure/app-configuration"5---67# Azure App Configuration SDK for TypeScript89Centralized configuration management with feature flags and dynamic refresh.1011## Installation1213```bash14# Low-level CRUD SDK15npm install @azure/app-configuration @azure/identity1617# High-level provider (recommended for apps)18npm install @azure/app-configuration-provider @azure/identity1920# Feature flag management21npm install @microsoft/feature-management22```2324## Environment Variables2526```bash27AZURE_APPCONFIG_ENDPOINT=https://<your-resource>.azconfig.io28# OR29AZURE_APPCONFIG_CONNECTION_STRING=Endpoint=https://...;Id=...;Secret=...30```3132## Authentication3334```typescript35import { AppConfigurationClient } from "@azure/app-configuration";36import { DefaultAzureCredential } from "@azure/identity";3738// DefaultAzureCredential (recommended)39const client = new AppConfigurationClient(40 process.env.AZURE_APPCONFIG_ENDPOINT!,41 new DefaultAzureCredential()42);4344// Connection string45const client2 = new AppConfigurationClient(46 process.env.AZURE_APPCONFIG_CONNECTION_STRING!47);48```4950## CRUD Operations5152### Create/Update Settings5354```typescript55// Add new (fails if exists)56await client.addConfigurationSetting({57 key: "app:settings:message",58 value: "Hello World",59 label: "production",60 contentType: "text/plain",61 tags: { environment: "prod" },62});6364// Set (create or update)65await client.setConfigurationSetting({66 key: "app:settings:message",67 value: "Updated value",68 label: "production",69});7071// Update with optimistic concurrency72const existing = await client.getConfigurationSetting({ key: "myKey" });73existing.value = "new value";74await client.setConfigurationSetting(existing, { onlyIfUnchanged: true });75```7677### Read Settings7879```typescript80// Get single setting81const setting = await client.getConfigurationSetting({82 key: "app:settings:message",83 label: "production", // optional84});85console.log(setting.value);8687// List with filters88const settings = client.listConfigurationSettings({89 keyFilter: "app:*",90 labelFilter: "production",91});9293for await (const setting of settings) {94 console.log(`${setting.key}: ${setting.value}`);95}96```9798### Delete Settings99100```typescript101await client.deleteConfigurationSetting({102 key: "app:settings:message",103 label: "production",104});105```106107### Lock/Unlock (Read-Only)108109```typescript110// Lock111await client.setReadOnly({ key: "myKey", label: "prod" }, true);112113// Unlock114await client.setReadOnly({ key: "myKey", label: "prod" }, false);115```116117## App Configuration Provider118119### Load Configuration120121```typescript122import { load } from "@azure/app-configuration-provider";123import { DefaultAzureCredential } from "@azure/identity";124125const appConfig = await load(126 process.env.AZURE_APPCONFIG_ENDPOINT!,127 new DefaultAzureCredential(),128 {129 selectors: [130 { keyFilter: "app:*", labelFilter: "production" },131 ],132 trimKeyPrefixes: ["app:"],133 }134);135136// Map-style access137const value = appConfig.get("settings:message");138139// Object-style access140const config = appConfig.constructConfigurationObject({ separator: ":" });141console.log(config.settings.message);142```143144### Dynamic Refresh145146```typescript147const appConfig = await load(endpoint, credential, {148 selectors: [{ keyFilter: "app:*" }],149 refreshOptions: {150 enabled: true,151 refreshIntervalInMs: 30_000, // 30 seconds152 },153});154155// Trigger refresh (non-blocking)156appConfig.refresh();157158// Listen for refresh events159const disposer = appConfig.onRefresh(() => {160 console.log("Configuration refreshed!");161});162163// Express middleware pattern164app.use((req, res, next) => {165 appConfig.refresh();166 next();167});168```169170### Key Vault References171172```typescript173const appConfig = await load(endpoint, credential, {174 selectors: [{ keyFilter: "app:*" }],175 keyVaultOptions: {176 credential: new DefaultAzureCredential(),177 secretRefreshIntervalInMs: 7200_000, // 2 hours178 },179});180181// Secrets are automatically resolved182const dbPassword = appConfig.get("database:password");183```184185## Feature Flags186187### Create Feature Flag (Low-Level)188189```typescript190import {191 featureFlagPrefix,192 featureFlagContentType,193 FeatureFlagValue,194 ConfigurationSetting,195} from "@azure/app-configuration";196197const flag: ConfigurationSetting<FeatureFlagValue> = {198 key: `${featureFlagPrefix}Beta`,199 contentType: featureFlagContentType,200 value: {201 id: "Beta",202 enabled: true,203 description: "Beta feature",204 conditions: {205 clientFilters: [206 {207 name: "Microsoft.Targeting",208 parameters: {209 Audience: {210 Users: ["user@example.com"],211 Groups: [{ Name: "beta-testers", RolloutPercentage: 50 }],212 DefaultRolloutPercentage: 0,213 },214 },215 },216 ],217 },218 },219};220221await client.addConfigurationSetting(flag);222```223224### Load and Evaluate Feature Flags225226```typescript227import { load } from "@azure/app-configuration-provider";228import {229 ConfigurationMapFeatureFlagProvider,230 FeatureManager,231} from "@microsoft/feature-management";232233const appConfig = await load(endpoint, credential, {234 featureFlagOptions: {235 enabled: true,236 selectors: [{ keyFilter: "*" }],237 refresh: {238 enabled: true,239 refreshIntervalInMs: 30_000,240 },241 },242});243244const featureProvider = new ConfigurationMapFeatureFlagProvider(appConfig);245const featureManager = new FeatureManager(featureProvider);246247// Simple check248const isEnabled = await featureManager.isEnabled("Beta");249250// With targeting context251const isEnabledForUser = await featureManager.isEnabled("Beta", {252 userId: "user@example.com",253 groups: ["beta-testers"],254});255```256257## Snapshots258259```typescript260// Create snapshot261const snapshot = await client.beginCreateSnapshotAndWait({262 name: "release-v1.0",263 retentionPeriod: 2592000, // 30 days264 filters: [{ keyFilter: "app:*", labelFilter: "production" }],265});266267// Get snapshot268const snap = await client.getSnapshot("release-v1.0");269270// List settings in snapshot271const settings = client.listConfigurationSettingsForSnapshot("release-v1.0");272for await (const setting of settings) {273 console.log(`${setting.key}: ${setting.value}`);274}275276// Archive/recover277await client.archiveSnapshot("release-v1.0");278await client.recoverSnapshot("release-v1.0");279280// Load from snapshot (provider)281const config = await load(endpoint, credential, {282 selectors: [{ snapshotName: "release-v1.0" }],283});284```285286## Labels287288```typescript289// Create settings with labels290await client.setConfigurationSetting({291 key: "database:host",292 value: "dev-db.example.com",293 label: "development",294});295296await client.setConfigurationSetting({297 key: "database:host",298 value: "prod-db.example.com",299 label: "production",300});301302// Filter by label303const prodSettings = client.listConfigurationSettings({304 keyFilter: "*",305 labelFilter: "production",306});307308// No label (null label)309const noLabelSettings = client.listConfigurationSettings({310 labelFilter: "\0",311});312313// List available labels314for await (const label of client.listLabels()) {315 console.log(label.name);316}317```318319## Key Types320321```typescript322import {323 AppConfigurationClient,324 ConfigurationSetting,325 FeatureFlagValue,326 SecretReferenceValue,327 featureFlagPrefix,328 featureFlagContentType,329 secretReferenceContentType,330 ListConfigurationSettingsOptions,331} from "@azure/app-configuration";332333import { load } from "@azure/app-configuration-provider";334335import {336 FeatureManager,337 ConfigurationMapFeatureFlagProvider,338} from "@microsoft/feature-management";339```340341## Best Practices3423431. **Use provider for apps** - `@azure/app-configuration-provider` for runtime config3442. **Use low-level for management** - `@azure/app-configuration` for CRUD operations3453. **Enable refresh** - For dynamic configuration updates3464. **Use labels** - Separate configurations by environment3475. **Use snapshots** - For immutable release configurations3486. **Sentinel pattern** - Use a sentinel key to trigger full refresh3497. **RBAC roles** - `App Configuration Data Reader` for read-only access350
Full transparency — inspect the skill content before installing.