1 | # Azure App Configuration client library for JS
|
2 |
|
3 | Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely.
|
4 |
|
5 | Modern programs, especially programs running in a cloud, generally have many components that are distributed in nature. Spreading configuration settings across these components can lead to hard-to-troubleshoot errors during an application deployment. Use App Configuration to securely store all the settings for your application in one place.
|
6 |
|
7 | Use the client library for App Configuration to:
|
8 |
|
9 | * Create centrally stored application configuration settings
|
10 | * Retrieve settings
|
11 | * Update settings
|
12 | * Delete settings
|
13 |
|
14 | [NPM](https://www.npmjs.com/package/@azure/app-configuration) | [Product documentation](https://docs.microsoft.com/en-us/azure/azure-app-configuration/)
|
15 |
|
16 | ## Getting started
|
17 |
|
18 | ### Currently supported environments
|
19 |
|
20 | - Node.js version 8.x.x or higher
|
21 |
|
22 | ### How to Install
|
23 |
|
24 | ```bash
|
25 | npm install @azure/app-configuration
|
26 | ```
|
27 |
|
28 | ## Key concepts
|
29 |
|
30 | ### Configuration Setting
|
31 |
|
32 | A Configuration Setting is the fundamental resource within a Configuration Store.
|
33 | In its simplest form, it is a key and a value. However, there are additional properties such as
|
34 | the modifiable content type and tags fields that allows the value to be interpreted or associated
|
35 | in different ways.
|
36 |
|
37 | The `label` property of a Configuration Setting provides a way to separate configuration settings
|
38 | into different dimensions. These dimensions are user defined and can take any form. Some common
|
39 | examples of dimensions to use for a label include regions, semantic versions, or environments.
|
40 | Many applications have a required set of configuration keys that have varying values as the
|
41 | application exists across different dimensions.
|
42 |
|
43 | For example, MaxRequests may be 100 in "NorthAmerica", and 200 in "WestEurope". By creating a
|
44 | Configuration Setting named MaxRequests with a label of "NorthAmerica" and another, only with
|
45 | a different value, in the "WestEurope" label, an application can seamlessly retrieve
|
46 | Configuration Settings as it runs in these two dimensions.
|
47 |
|
48 | ## Examples
|
49 |
|
50 | #### nodejs - Authentication, client creation and listConfigurationSettings as an example written in TypeScript.
|
51 |
|
52 | ##### Sample code
|
53 |
|
54 | ```typescript
|
55 | import { AppConfigurationClient } from "@azure/app-configuration";
|
56 |
|
57 | const connectionString = process.env["AZ_CONFIG_CONNECTION"]!;
|
58 | const client = new AppConfigurationClient(connectionString);
|
59 |
|
60 | let configurationSetting = await client.getConfigurationSetting("testkey");
|
61 |
|
62 | console.log("The result is:");
|
63 | console.log(configurationSetting.value);
|
64 | ```
|
65 |
|
66 | More examples can be found in the samples folder on [github](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/appconfiguration/app-configuration/samples)
|
67 |
|
68 | ## Next steps
|
69 |
|
70 | Explore the samples to understand how to work with Azure App Configuration.
|
71 |
|
72 | * [`helloworld.ts`](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/appconfiguration/app-configuration/samples/helloworld.ts) - getting, setting and deleting configuration values
|
73 | * [`helloworldWithLabels.ts`](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/appconfiguration/app-configuration/samples/helloworldWithLabels.ts) - using labels to add additional dimensions to your settings
|
74 | * [`helloworldWithETag.ts`](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/appconfiguration/app-configuration/samples/helloworldWithETag.ts) - setting values using etags to prevent accidental overwrites
|
75 |
|
76 | ## Contributing
|
77 |
|
78 | This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
79 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
80 | the rights to use your contribution. For details, visit <https://cla.microsoft.com.>
|
81 |
|
82 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
83 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
84 | provided by the bot. You will only need to do this once across all repos using our CLA.
|
85 |
|
86 | If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/master/CONTRIBUTING.md) to learn more about how to build and test the code.
|
87 |
|
88 | This module's tests are live tests, which require you to have an Azure App Configuration instance. To execute the tests
|
89 | you'll need to run:
|
90 | 1. `rush update`
|
91 | 2. `rush build`
|
92 | 3. `npm run test`.
|
93 |
|
94 | View our tests ([index.spec.ts](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/appconfiguration/app-configuration/test/index.spec.ts)) for more details.
|
95 |
|
96 | ## Related projects
|
97 |
|
98 | - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)
|
99 |
|
100 | ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/appconfiguration/app-config/README.png)
|