Skip to content

Update README for examples #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,37 @@ Samples retrieve credentials to access your App Configuration store from environ
Alternatively, edit the source code to include the appropriate credentials.
See each individual sample for details on which environment variables/credentials it requires to function.

## Setup
## Add a key-value
Add the following key-value to the App Configuration store and leave Label and Content Type with their default values. For more information about how to add key-values to a store using the Azure portal or the CLI, go to [Create a key-value](./quickstart-azure-app-configuration-create.md#create-a-key-value).

To run the samples using the published version of the package:
| Key | Value |
|------------------------|----------------|
| *app.settings.message* | *Hello World!* |

## Setup & Run

To run the examples using the published version of the package:

1. Install the dependencies using `npm`:

```bash
npm install
```

2. There are two ways to run the samples using correct credentials:
2. There are two ways to run the examples using correct credentials:

- Edit the file `.env.template`, adding the access keys to your App Configuration store. and rename the file from `.env.template` to just `.env`. The example programs will read this file automatically.

- Edit the file `.env.template`, adding the correct credentials to access your Azure App Configuration store and rename the file from `.env.template` to just `.env`.
Then run the samples, it will read this file automatically.
- Alternatively, you can set the environment variables to the access keys to your App Configuration store. In this case, setting up the `.env` file is not required.
```bash
npx cross-env APPCONFIG_CONNECTION_STRING="<appconfig connection string>"
```

3. Run the example:
```bash
node helloworld.mjs
```

- Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform):
```bash
npx cross-env APPCONFIG_CONNECTION_STRING="<appconfig connection string>" node helloworld.mjs
You should see the following output:
```Output
Message from Azure App Configuration: Hello World!
```