Skip to content

Commit 41b088f

Browse files
wip
1 parent 5abb866 commit 41b088f

File tree

5 files changed

+114
-9
lines changed

5 files changed

+114
-9
lines changed

articles/azure-app-configuration/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@
310310
href: https://go.microsoft.com/fwlink/?linkid=2180917
311311
- name: Python provider
312312
href: https://pypi.org/project/azure-appconfiguration-provider/
313+
- name: JavaScript provider
314+
href: ./reference-javascript-provider.md
313315
- name: Azure SDK for .NET
314316
href: https://go.microsoft.com/fwlink/?linkid=2092056
315317
- name: Azure SDK for Java

articles/azure-app-configuration/enable-dynamic-configuration-javascript.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,8 @@ In this tutorial, you enabled your JavaScript app to dynamically refresh configu
221221

222222
> [!div class="nextstepaction"]
223223
> [Managed identity integration](./howto-integrate-azure-managed-service-identity.md)
224+
225+
For the full feature rundown of the JavaScript configuration provider library, continue to the following document.
226+
227+
> [!div class="nextstepaction"]
228+
> [JavaScript configuration provider](./reference-javascript-provider.md)

articles/azure-app-configuration/feature-management-dotnet-reference.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,8 +1191,6 @@ ActivitySource.AddActivityListener(new ActivityListener()
11911191

11921192
For more information, please go to [Collect a distributed trace](/dotnet/core/diagnostics/distributed-tracing-collection-walkthroughs).
11931193

1194-
1195-
11961194
### Application Insights Telemetry
11971195

11981196
The `Microsoft.FeatureManagement.Telemetry.ApplicationInsights` package provides a built-in telemetry publisher that sends feature flag evaluation data to [Application Insights](/azure/azure-monitor/app/app-insights-overview). The `Microsoft.FeatureManagement.Telemetry.ApplicationInsights` package also provides a telemetry initializer that automatically tags all events with `TargetingId` so that events may be linked to flag evaluations. To take advantage of this, add a reference to the package and register the Application Insights telemetry as in the following example.

articles/azure-app-configuration/quickstart-javascript-provider.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,4 +408,9 @@ run().catch(console.error);
408408
In this quickstart, you created a new App Configuration store and learned how to access key-values using the App Configuration JavaScript provider in a Node.js app. To learn how to configure your app to dynamically refresh configuration settings, continue to the next tutorial.
409409
410410
> [!div class="nextstepaction"]
411-
> [Enable dynamic configuration](./enable-dynamic-configuration-javascript.md)
411+
> [Enable dynamic configuration](./enable-dynamic-configuration-javascript.md)
412+
413+
For the full feature rundown of the JavaScript configuration provider library, continue to the following document.
414+
415+
> [!div class="nextstepaction"]
416+
> [JavaScript configuration provider](./reference-javascript-provider.md)

articles/azure-app-configuration/reference-javascript-provider.md

Lines changed: 101 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,118 @@ ms.date: 02/02/2025
1717

1818
[![configuration-provider-npm-package](https://img.shields.io/npm/v/@azure/app-configuration-provider?label=@azure/app-configuration-provider)](https://www.npmjs.com/package/@azure/app-configuration-provider)
1919

20+
Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. The JavaScript configuration provider library enables loading configuration from an Azure App Configuration store in a managed way. This client library adds additional functionality above the Azure sdk for JavaScript.
21+
2022
## Load configuration
2123

22-
### Connect to Azure App Configuration
24+
The `load` method exported in the `@azure/app-configuration-provider` package is used to load configuration from the Azure App Configuration. The `load` method allows you to either use Microsoft Entra ID or connection string to connect to the App Configuration store.
2325

24-
### Load specific key-values using selectors
26+
### [Microsoft Entra ID](#tab/entra-id)
2527

26-
### Load key-values and trim prefix from keys
28+
You use the `DefaultAzureCredential` to authenticate to your App Configuration store. Follow the [instructions](./concept-enable-rbac.md#authentication-with-token-credentials) to assign your credential the **App Configuration Data Reader** role.
2729

28-
## Use Key Vault reference
30+
```javascript
31+
const { load } = require("@azure/app-configuration-provider");
32+
const { DefaultAzureCredential } = require("@azure/identity");
33+
const endpoint = process.env.AZURE_APPCONFIG_ENDPOINT;
34+
const credential = new DefaultAzureCredential(); // For more information, see https://learn.microsoft.com/azure/developer/javascript/sdk/credential-chains#use-defaultazurecredential-for-flexibility
35+
36+
async function run() {
37+
// Connect to Azure App Configuration using a token credential and load all key-values with null label.
38+
const settings = await load(endpoint, credential);
39+
console.log('settings.get("message"):', settings.get("message"));
40+
}
41+
42+
run();
43+
```
44+
45+
### [Connection string](#tab/connection-string)
46+
47+
```javascript
48+
const { load } = require("@azure/app-configuration-provider");
49+
const connectionString = process.env.AZURE_APPCONFIG_CONNECTION_STRING;
50+
51+
async function run() {
52+
// Connect to Azure App Configuration using a connection string and load all key-values with null label.
53+
const settings = await load(connectionString);
54+
console.log('settings.get("message"):', settings.get("message"));
55+
}
56+
57+
run();
58+
```
59+
60+
---
61+
62+
The `load` method returns an instance of `AzureAppConfiguration` type which is defined as follows:
63+
64+
```typescript
65+
type AzureAppConfiguration = {
66+
refresh(): Promise<void>;
67+
onRefresh(listener: () => any, thisArg?: any): Disposable;
68+
} & IGettable & ReadonlyMap<string, any> & IConfigurationObject;
69+
```
70+
71+
For more information about `refresh` and `onRefresh` methods, see the [Dynamic refresh](#dynamic-refresh) section.
72+
73+
### Consume configuration
74+
75+
The `AzureAppConfiguration` type extends the following interfaces:
2976

30-
## Use feature flag
77+
- `IGettable`
3178

79+
```typescript
80+
interface IGettable {
81+
get<T>(key: string): T | undefined;
82+
}
83+
```
3284

85+
The `IGettable` interface provides `get` method to retrieve the value of a key-value from the Map-styled data structure.
86+
87+
```typescript
88+
const settings = await load(endpoint, credential);
89+
const fontSize = settings.get("app:font:size"); // value of the key "app:font:size" from the App Configuration store
90+
```
91+
92+
- `ReadonlyMap`
93+
94+
The `AzureAppConfiguration` type also extends the [`ReadonlyMap`](https://typestrong.org/typedoc-auto-docs/typedoc/interfaces/TypeScript.ReadonlyMap.html) interface, providing read-only access to key-value pairs.
95+
96+
- `IConfigurationObject`
97+
98+
```typescript
99+
interface IConfigurationObject {
100+
constructConfigurationObject(options?: ConfigurationObjectConstructionOptions): Record<string, any>;
101+
}
102+
```
103+
104+
The `IConfigurationObject` interface provides `constructConfigurationObject` method to construct a configuration object based on a Map-styled data structure and hierarchical keys. The optional `ConfigurationObjectConstructionOptions` parameter can be used to specify the separator for converting hierarchical keys to object properties. By default, the separator is `"."`.
105+
106+
```typescript
107+
interface ConfigurationObjectConstructionOptions {
108+
separator?: "." | "," | ";" | "-" | "_" | "__" | "/" | ":"; // supported separators
109+
}
110+
```
111+
112+
In JavaScript, objects or maps are commonly used as the primary data structures to represent configurations. The JavaScript configuration provider library supports both of the configuration approaches, providing developers with the flexibility to choose the option that best fits their needs.
113+
114+
```typescript
115+
const settings = await load(endpoint, credential);
116+
const settingsObj = settings.constructConfigurationObject({separator: ":"});
117+
const fontSize1 = settings.get("app:font:size"); // map-style configuration representation
118+
const fontSize2 = settingsObj.app.font.size; // object-style configuration representation
119+
```
120+
121+
### Load specific key-values using selectors
122+
123+
### Load feature flag
124+
125+
### Trim prefix from keys
126+
127+
## Use Key Vault reference
33128

34129

35130

36-
## Refresh configuration
131+
## Dynamic refresh
37132

38133
### Watch sentinel key for refresh
39134

0 commit comments

Comments
 (0)