Skip to content

Commit 1eef45f

Browse files
committed
PR update followingr review
1 parent c860099 commit 1eef45f

File tree

1 file changed

+78
-117
lines changed

1 file changed

+78
-117
lines changed

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

Lines changed: 78 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.author: malev
1515

1616
This document shows examples of how to use the [Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/appconfiguration/app-configuration) to access key-values in Azure App Configuration.
1717

18-
>[!TIP]
18+
>[!IMPORTANT]
1919
> App Configuration offers a JavaScript provider library that is built on top of the JavaScript SDK and is designed to be easier to use with richer features. It enables configuration settings to be used like a Map object, and offers other features like configuration composition from multiple labels, key name trimming, and automatic resolution of Key Vault references. Go to the [JavaScript quickstart](./quickstart-javascript-provider.md) to learn more.
2020
2121
## Prerequisites
@@ -68,94 +68,6 @@ Add the following key-value to the App Configuration store and leave **Label** a
6868
> [!NOTE]
6969
> The code snippets in this example will help you get started with the App Configuration client library for JavaScript. For your application, you should also consider handling exceptions according to your needs. To learn more about exception handling, please refer to our [JavaScript SDK documentation](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/appconfiguration/app-configuration).
7070

71-
## Configure an environment variable
72-
73-
1. Configure an environment variable using Microsoft Entra ID (recommended) or a connection string.
74-
75-
### [Microsoft Entra ID (recommended)](#tab/entra-id)
76-
77-
Set an environment variable named **AZURE_APPCONFIG_ENDPOINT** to the endpoint of your App Configuration store found under the **Overview** of your store in the Azure portal.
78-
79-
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
80-
81-
```cmd
82-
setx AZURE_APPCONFIG_ENDPOINT "endpoint-of-your-app-configuration-store"
83-
```
84-
85-
If you use PowerShell, run the following command:
86-
87-
```powershell
88-
$Env:AZURE_APPCONFIG_ENDPOINT = "endpoint-of-your-app-configuration-store"
89-
```
90-
91-
If you use macOS or Linux, run the following command:
92-
93-
```bash
94-
export AZURE_APPCONFIG_ENDPOINT='<endpoint-of-your-app-configuration-store>'
95-
```
96-
97-
### [Connection string](#tab/connection-string)
98-
99-
Set an environment variable named **AZURE_APPCONFIG_CONNECTION_STRING** to the read-only connection string of your App Configuration store found under **Access keys** of your store in the Azure portal.
100-
101-
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
102-
103-
```cmd
104-
setx AZURE_APPCONFIG_CONNECTION_STRING "<connection-string-of-your-app-configuration-store>"
105-
```
106-
107-
If you use PowerShell, run the following command:
108-
109-
```powershell
110-
$Env:AZURE_APPCONFIG_CONNECTION_STRING = "connection-string-of-your-app-configuration-store"
111-
```
112-
113-
If you use macOS or Linux, run the following command:
114-
115-
```bash
116-
export AZURE_APPCONFIG_CONNECTION_STRING='<connection-string-of-your-app-configuration-store>'
117-
```
118-
---
119-
120-
1. Print out the value of the environment variable to validate that it is set properly with the command below.
121-
122-
### [Microsoft Entra ID (recommended)](#tab/entra-id)
123-
124-
```cmd
125-
echo AZURE_APPCONFIG_ENDPOINT
126-
```
127-
128-
If you use PowerShell, run the following command:
129-
130-
```powershell
131-
$Env:AZURE_APPCONFIG_ENDPOINT
132-
```
133-
134-
If you use macOS or Linux, run the following command:
135-
136-
```bash
137-
export AZURE_APPCONFIG_ENDPOINT
138-
```
139-
140-
### [Connection string](#tab/connection-string)
141-
142-
```cmd
143-
echo AZURE_APPCONFIG_CONNECTION_STRING
144-
```
145-
146-
If you use PowerShell, run the following command:
147-
148-
```powershell
149-
$Env:AZURE_APPCONFIG_CONNECTION_STRING
150-
```
151-
152-
If you use macOS or Linux, run the following command:
153-
154-
```bash
155-
export AZURE_APPCONFIG_CONNECTION_STRING
156-
```
157-
---
158-
15971
## Code samples
16072

16173
The sample code snippets in this section show you how to perform common operations with the App Configuration client library for JavaScript. Add these code snippets to the body of `run` function in *app-configuration-example.js* file you created earlier.
@@ -190,7 +102,7 @@ const client = new AppConfigurationClient(
190102
process.env.AZURE_APPCONFIG_ENDPOINT,
191103
new DefaultAzureCredential()
192104
);
193-
105+
```
194106

195107
### [Connection string](#tab/connection-string)
196108

@@ -400,37 +312,86 @@ run().catch(console.error);
400312
```
401313
---
402314

403-
In your console window, navigate to the directory containing the *app-configuration-example.js* file and execute the following command to run the app:
404-
405-
```console
406-
node app.js
407-
```
408-
409-
You should see the following output:
410-
411-
```output
412-
Azure App Configuration - JavaScript example
413-
414-
Retrieved configuration setting:
415-
Key: TestApp:Settings:Message, Value: Data from Azure App Configuration
416-
417-
Added configuration setting:
418-
Key: TestApp:Settings:NewSetting, Value: New setting value
419-
420-
Retrieved list of configuration settings:
421-
Key: TestApp:Settings:Message, Value: Data from Azure App Configuration
422-
Key: TestApp:Settings:NewSetting, Value: New setting value
315+
## Configure an environment variable
423316

424-
Read-only status for TestApp:Settings:NewSetting: true
317+
1. Configure an environment variable using Microsoft Entra ID (recommended) or a connection string.
425318

426-
Read-only status for TestApp:Settings:NewSetting: false
319+
### [Microsoft Entra ID (recommended)](#tab/entra-id)
320+
321+
Set an environment variable named **AZURE_APPCONFIG_ENDPOINT** to the endpoint of your App Configuration store found under the **Overview** of your store in the Azure portal.
322+
323+
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
324+
325+
```cmd
326+
setx AZURE_APPCONFIG_ENDPOINT "endpoint-of-your-app-configuration-store"
327+
```
328+
329+
If you use PowerShell, run the following command:
330+
331+
```powershell
332+
$Env:AZURE_APPCONFIG_ENDPOINT = "endpoint-of-your-app-configuration-store"
333+
```
334+
335+
If you use macOS or Linux, run the following command:
336+
337+
```bash
338+
export AZURE_APPCONFIG_ENDPOINT='<endpoint-of-your-app-configuration-store>'
339+
```
340+
341+
### [Connection string](#tab/connection-string)
342+
343+
Set an environment variable named **AZURE_APPCONFIG_CONNECTION_STRING** to the read-only connection string of your App Configuration store found under **Access keys** of your store in the Azure portal.
344+
345+
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
346+
347+
```cmd
348+
setx AZURE_APPCONFIG_CONNECTION_STRING "<connection-string-of-your-app-configuration-store>"
349+
```
350+
351+
If you use PowerShell, run the following command:
352+
353+
```powershell
354+
$Env:AZURE_APPCONFIG_CONNECTION_STRING = "connection-string-of-your-app-configuration-store"
355+
```
356+
357+
If you use macOS or Linux, run the following command:
358+
359+
```bash
360+
export AZURE_APPCONFIG_CONNECTION_STRING='<connection-string-of-your-app-configuration-store>'
361+
```
362+
---
427363
428-
Updated configuration setting:
429-
Key: TestApp:Settings:NewSetting, Value: Value has been updated!
364+
1. In your console window, navigate to the directory containing the *app-configuration-example.js* file and execute the following command to run the app:
430365
431-
Deleted configuration setting:
432-
Key: TestApp:Settings:NewSetting, Value: Value has been updated!
433-
```
366+
```console
367+
node app.js
368+
```
369+
370+
You should see the following output:
371+
372+
```output
373+
Azure App Configuration - JavaScript example
374+
375+
Retrieved configuration setting:
376+
Key: TestApp:Settings:Message, Value: Data from Azure App Configuration
377+
378+
Added configuration setting:
379+
Key: TestApp:Settings:NewSetting, Value: New setting value
380+
381+
Retrieved list of configuration settings:
382+
Key: TestApp:Settings:Message, Value: Data from Azure App Configuration
383+
Key: TestApp:Settings:NewSetting, Value: New setting value
384+
385+
Read-only status for TestApp:Settings:NewSetting: true
386+
387+
Read-only status for TestApp:Settings:NewSetting: false
388+
389+
Updated configuration setting:
390+
Key: TestApp:Settings:NewSetting, Value: Value has been updated!
391+
392+
Deleted configuration setting:
393+
Key: TestApp:Settings:NewSetting, Value: Value has been updated!
394+
```
434395
435396
## Clean up resources
436397

0 commit comments

Comments
 (0)