Skip to content

Commit 779ecbc

Browse files
authored
use env secret store (#231)
Signed-off-by: Filinto Duran <[email protected]>
1 parent 32c70b0 commit 779ecbc

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

quickstarts/05-multi-agent-workflows/README.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ OPENAI_API_KEY=your_api_key_here
6969

7070
2. Configure the OpenAI component. You have two options:
7171

72-
a. Directly update the `key` in [components/openai.yaml](components/openai.yaml):
72+
a. Directly update the `key` in [components/openai.yaml](components/openai.yaml), and remove the secretKeyRef:
7373
```yaml
7474
metadata:
7575
- name: key
@@ -78,21 +78,10 @@ OPENAI_API_KEY=your_api_key_here
7878
7979
b. Use environment variables (recommended):
8080
```bash
81-
# Get the environment variables from the .env file:
81+
# Get the environment variables from the .env file exported to be use
8282
export $(grep -v '^#' ../../.env | xargs)
83-
84-
# Create a temporary resources folder with resolved environment variables
85-
temp_resources_folder=$(../resolve_env_templates.py ./components)
86-
87-
# Use the temporary folder when running your dapr commands
88-
dapr run -f dapr-random.yaml --resources-path $temp_resources_folder
89-
90-
# Clean up the temporary folder when done
91-
rm -rf $temp_resources_folder
9283
```
9384

94-
Note: The temporary resources folder will be automatically deleted when the Dapr sidecar is stopped or when the computer is restarted.
95-
9685
3. Make sure Dapr is initialized on your system:
9786

9887
```bash
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: dapr.io/v1alpha1
2+
kind: Component
3+
metadata:
4+
name: envvar-secret-store
5+
spec:
6+
type: secretstores.local.env
7+
version: v1
8+
metadata:
9+
# to limit what environment variables are loaded into the secret store to only those prefixed with "MYAPP_"
10+
# - name: prefix
11+
# value: "MYAPP_"

quickstarts/05-multi-agent-workflows/components/openai.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ spec:
77
version: v1
88
metadata:
99
- name: key
10-
value: "{{OPENAI_API_KEY}}"
10+
# we could also use the key directly here but is not recommended
11+
# value: "{{OPENAI_API_KEY}}"
12+
secretKeyRef: # using environment variable secret store
13+
name: OPENAI_API_KEY
14+
key: OPENAI_API_KEY
1115
- name: model
12-
value: gpt-4o-mini
16+
value: gpt-5-2025-08-07
1317
- name: temperature
1418
value: 1
19+
auth:
20+
secretStore: envvar-secret-store

0 commit comments

Comments
 (0)