Skip to content

Commit c1d3340

Browse files
(MAINT) Editing pass for secret function reference
1 parent 33189d4 commit c1d3340

1 file changed

Lines changed: 92 additions & 36 deletions

File tree

  • docs/reference/schemas/config/functions

docs/reference/schemas/config/functions/secret.md

Lines changed: 92 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,25 @@ secret(<name>, <vault>)
2020

2121
## Description
2222

23-
The `secret()` function retrieves secrets from extensions that support the
24-
secret capability. It queries all registered extensions that implement secret
25-
management and returns the requested secret value. If multiple extensions
26-
return different values for the same secret name, an error is returned unless
27-
a vault is specified to disambiguate.
23+
The `secret()` function retrieves secrets from extensions that support the secret capability. It
24+
queries all registered extensions that implement secret management and returns the requested secret
25+
value. If multiple extensions return different values for the same secret name, an error is
26+
returned unless a vault is specified to disambiguate.
2827

2928
The function supports two calling patterns:
3029

3130
- Single argument: Retrieves a secret by name from any available vault
3231
- Two arguments: Retrieves a secret by name from a specific vault
3332

34-
If multiple extensions return the same secret value, the function succeeds and
35-
returns that value. This allows for redundancy across secret management
36-
systems.
33+
If multiple extensions return the same secret value, the function succeeds and returns that value.
34+
This allows for redundancy across secret management systems.
3735

3836
## Examples
3937

4038
### Example 1 - Retrieve a secret by name
4139

42-
The following example retrieves a secret named 'DatabasePassword' from any
43-
available vault. The secret expression is used directly as the output value.
40+
The following example retrieves a secret named `DatabasePassword` from any available vault. The
41+
secret expression is used directly as the output value.
4442

4543
```yaml
4644
# secret.example.1.dsc.config.yaml
@@ -57,8 +55,30 @@ dsc config get --file secret.example.1.dsc.config.yaml
5755
```
5856

5957
```yaml
58+
executionInformation:
59+
duration: PT11.2326172S
60+
endDatetime: 2026-05-05T09:55:33.313388600-05:00
61+
executionType: actual
62+
operation: get
63+
securityContext: restricted
64+
startDatetime: 2026-05-05T09:55:22.080771400-05:00
65+
version: 3.2.0
66+
metadata:
67+
Microsoft.DSC:
68+
duration: PT11.2325964S
69+
endDatetime: 2026-05-05T09:55:33.313367800-05:00
70+
executionType: actual
71+
operation: get
72+
securityContext: restricted
73+
startDatetime: 2026-05-05T09:55:22.080771400-05:00
74+
version: 3.2.0
6075
results:
61-
- name: Database Connection
76+
- executionInformation:
77+
duration: PT2.0098514S
78+
metadata:
79+
Microsoft.DSC:
80+
duration: PT2.0098514S
81+
name: Database Connection
6282
type: Microsoft.DSC.Debug/Echo
6383
result:
6484
actualState:
@@ -67,11 +87,20 @@ messages: []
6787
hadErrors: false
6888
```
6989
90+
> [!NOTE]
91+
> In this example the secret is emitted in plain text in the output. This is because the `secret`
92+
> function doesn't automatically wrap the result in a `secureString` wrapper. It passes the
93+
> discovered secret directly to the resource as a string.
94+
>
95+
> DSC doesn't emit secrets to the console or through trace messages itself. However, DSC can't
96+
> control whether a resource emits secrets. In this case, the secret was emitted by the `Echo`
97+
> resource in its output. For more information about handling secrets in a configuration, see
98+
> [Security considerations](#security-considerations).
99+
70100
### Example 2 - Pass a secret through a parameter default
71101

72-
The following example defines a secureString parameter whose default value
73-
is the secret. The resource then uses the parameter value for the output
74-
property.
102+
The following example defines a `secureString` parameter whose default value is the secret. The
103+
resource then uses the parameter value for the output property.
75104

76105
```yaml
77106
# secret.example.2.dsc.config.yaml
@@ -92,22 +121,51 @@ dsc config get --file secret.example.2.dsc.config.yaml
92121
```
93122

94123
```yaml
124+
executionInformation:
125+
duration: PT13.5097206S
126+
endDatetime: 2026-05-05T10:26:29.721210400-05:00
127+
executionType: actual
128+
operation: get
129+
securityContext: restricted
130+
startDatetime: 2026-05-05T10:26:16.211489800-05:00
131+
version: 3.2.0
132+
metadata:
133+
Microsoft.DSC:
134+
duration: PT13.5097028S
135+
endDatetime: 2026-05-05T10:26:29.721192600-05:00
136+
executionType: actual
137+
operation: get
138+
securityContext: restricted
139+
startDatetime: 2026-05-05T10:26:16.211489800-05:00
140+
version: 3.2.0
95141
results:
96-
- name: Database Connection
142+
- executionInformation:
143+
duration: PT1.451969S
144+
metadata:
145+
Microsoft.DSC:
146+
duration: PT1.451969S
147+
name: Database Connection
97148
type: Microsoft.DSC.Debug/Echo
98149
result:
99150
actualState:
100-
output: "MySecretPassword123"
151+
output: <secureValue>
101152
messages: []
102153
hadErrors: false
103154
```
104155

156+
> [!NOTE]
157+
> In this case, the value for the secret has been redacted because it was passed to the `Echo`
158+
> resource as a `secureString` value.
159+
105160
## Parameters
106161

107162
### name
108163

109164
The name of the secret to retrieve.
110165

166+
DSC passes this value to every extension with the `secret` capability as-is. Whether this value is
167+
case-sensitive depends on the extension and the secret vault that it uses.
168+
111169
```yaml
112170
Type: string
113171
Required: true
@@ -116,9 +174,12 @@ Position: 1
116174

117175
### vault
118176

119-
The name of the vault or secret store to retrieve the secret from. When
120-
specified, only the named vault is queried for the secret, which helps
121-
disambiguate when multiple vaults contain secrets with the same name.
177+
The name of the vault or secret store to retrieve the secret from. When specified, only the named
178+
vault is queried for the secret, which helps disambiguate when multiple vaults contain secrets with
179+
the same name.
180+
181+
DSC passes this value to every extension with the `secret` capability as-is. Whether this value is
182+
case-sensitive depends on the extension and the secret vault that it uses.
122183

123184
```yaml
124185
Type: string
@@ -150,23 +211,18 @@ The `secret()` function can return errors in the following situations:
150211

151212
## Security considerations
152213

153-
- Secret values are retrieved at runtime and should be handled securely
154-
- Secrets are not cached by DSC and are retrieved fresh on each function call
155-
- Secret values are logged when `--trace-level` is "TRACE"
156-
- Extensions should implement appropriate authentication and authorization for
157-
secret access
158-
159-
## Extension requirements
160-
161-
To support the `secret()` function, extensions must:
162-
163-
1. Declare the `secret` capability in their manifest
164-
2. Implement a secret retrieval method that accepts name and optional vault
165-
parameters
166-
3. Return secret values as single-line strings (multi-line values are not
167-
supported)
168-
4. Handle authentication and authorization according to their secret
169-
management system
214+
- DSC retrieves secret values at runtime and doesn't cache them.
215+
- DSC invokes the `secret` operation for every available extension with that capability on each
216+
usage of the `secret()` function in a configuration document.
217+
- When you invoke DSC with `--trace-level` as `TRACE`, unwrapped secret values are emitted in trace
218+
messages as part of the JSON Validation trace message for resource input.
219+
220+
When the secret values are wrapped as a `secureObject` or `secureString`, DSC redacts the value
221+
in trace messaging where it appears instead as `<secureValue>`.
222+
- DSC doesn't automatically wrap retrieved secrets as `secureString` instances. When a secret is
223+
wrapped as a `secureString`, like `{"secureString":"<secret>"}`, the resource is responsible for
224+
unwrapping the data. Check the JSON Schema and documentation for the resources you use to see
225+
whether they support `secureString` values.
170226

171227
## Related functions
172228

0 commit comments

Comments
 (0)