Skip to content

Commit 11f2e7a

Browse files
Update conceptual docs for v3 GA
1 parent 685b952 commit 11f2e7a

File tree

8 files changed

+1157
-1778
lines changed

8 files changed

+1157
-1778
lines changed

dsc/docs-conceptual/dsc-3.0/changelog.md

Lines changed: 12 additions & 1510 deletions
Large diffs are not rendered by default.

dsc/docs-conceptual/dsc-3.0/concepts/configurations.md

Lines changed: 97 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,47 @@ description: >-
33
DSC configuration documents are YAML or JSON data files that define the desired state of a system
44
declaratively. They are used to retrieve, validate, and enforce the state of multiple resource
55
instances.
6-
ms.date: 08/07/2023
7-
title: DSC Configuration Documents
6+
ms.date: 03/04/2025
7+
title: DSC configuration documents
88
---
99

10-
# DSC Configuration Documents
10+
# DSC configuration documents
1111

1212
<!-- markdownlint-disable MD013 -->
1313

1414
In Microsoft's Desired State Configuration (DSC) platform, DSC configuration documents declare the
1515
desired state of a system as data files. Configuration documents define a collection of
16-
[DSC Resource][01] instances to describe what the desired state should be, not how to put the
17-
system into that state. The DSC Resources handle the _how_ for the configuration document
18-
instances.
16+
[DSC resource][01] instances to describe what the desired state should be, not how to put the
17+
system into that state. The DSC resources handle the _how_ for each instance.
1918

20-
DSCv3 can process configuration documents to:
19+
DSC can process configuration documents to:
2120

2221
- Retrieve the current state of the defined resource instances with the `dsc config get` command.
2322
- Validate whether the instances are in the desired state with the `dsc config test` command.
2423
- Enforce the desired state for the instances with the `dsc config set` command.
24+
- Export a new configuration document with every instance of a set of resources with the
25+
`dsc config export` command.
2526

2627
Configuration documents are YAML or JSON files that contain a single object. The object's
27-
properties define how DSCv3 processes the document. The top-level properties for a document are:
28+
properties define how DSC processes the document. The top-level properties for a document are:
2829

29-
- `$schema` (required) - Defines the canonical URI for the JSON Schema the document adheres to. DSC
30+
- `$schema` (required) - Defines the URI for the JSON Schema the document adheres to. DSC
3031
uses this to know how to validate and interpret the document.
3132
- `resources` (required) - Defines the collection of resource instances the document manages.
32-
- `metadata` (optional) - Defines an arbitrary set of annotations for the document. DSC doesn't
33-
validate this data or use it directly. The annotations can include notes like who authored the
34-
document, the last time someone updated it, or any other information. DSC doesn't use the
35-
annotations. The metadata is for documentation or other tools to use.
33+
- `metadata` (optional) - Defines an arbitrary set of annotations for the document. Except for
34+
metadata within the `Microsoft.DSC` property, DSC doesn't validate this data or use it directly.
35+
The annotations can include notes like who authored the document, the last time someone updated
36+
it, or any other information. DSC doesn't use the annotations. The metadata is for documentation
37+
or other tools to use.
38+
39+
DSC applies validation to the `Microsoft.DSC` property. For more information, see the
40+
[DSC Configuration document metadata schema][02] reference.
3641
- `parameters` (optional) - Defines a set of runtime options for the configuration. Parameters can
3742
be referenced by resource instances to reduce duplicate definitions or enable dynamic values.
3843
Parameters can have default values and can be set on any configuration operation.
3944
- `variables` (optional) - Defines a set of reusable values for the configuration. Variables can be
4045
referenced by resource instances to reduce duplicate definitions.
4146

42-
> [!NOTE]
43-
> DSC isn't implemented to process the `parameters` and `variables` properties yet. They can be
44-
> defined in a document, but not referenced.
45-
4647
## Defining a configuration document
4748

4849
Minimally, a configuration document defines the `$schema` and `resources` properties. The
@@ -53,7 +54,7 @@ For example:
5354

5455
```yaml
5556
# example.dsc.config.yaml
56-
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.json
57+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
5758
resources:
5859
- name: example key value
5960
type: Microsoft.Windows/Registry
@@ -64,7 +65,7 @@ resources:
6465
String: This is an example.
6566
```
6667
67-
The example document defines a single resource instance called `example key value`. The instance
68+
The example document defines a single resource instance named `example key value`. The instance
6869
uses the `Microsoft.Windows/Registry` resource to declare the following desired state:
6970

7071
- The `example\key` registry key should exist in the system's current user hive.
@@ -75,17 +76,21 @@ The example document is _declarative_. It describes the desired state, not how t
7576
into that state. It relies on the `Microsoft.Windows/Registry` resource to handle getting, testing,
7677
and setting the state of the registry key and value.
7778

79+
For more information about the structure and validation of configuration documents, see
80+
[DSC Configuration document schema reference][03].
81+
7882
### Defining resource instances
7983

8084
As shown in the prior example, configuration documents include a collection of resource instances.
81-
Together, the instances describe the desired state of a system. A configuration document can include any
82-
number of resource instances.
85+
Together, the instances describe the desired state of a system. A configuration document can
86+
include any number of resource instances.
8387

8488
A resource instance declaration always includes:
8589

8690
- `name` - A short, human-readable name for the instance that's unique in the document. This name
8791
is used for logging and it helps describe the purpose of the instance.
88-
- `type` - The [fully qualified type name][02] of the resource that DSC should use to manage the instance.
92+
- `type` - The [fully qualified type name][04] of the resource that DSC should use to manage the
93+
instance.
8994
- `properties` - The desired state for the instance. DSC validates the values against the
9095
resource's instance schema.
9196

@@ -96,60 +101,86 @@ incompatible state for the instance on every run.
96101
## Getting the current state of a configuration
97102

98103
The `dsc config get` command retrieves the current state of the resource instances defined in a
99-
configuration document. DSC also collects any message emitted by the resources during the operation
100-
and indicates whether any of the resources raised an error.
104+
configuration document. DSC also collects any message emitted by the resources during the
105+
operation, indicates whether any of the resources raised an error, and provides metadata about the
106+
operation as a whole and for each resource instance.
101107

102108
```sh
103-
cat ./example.config.dsc.yaml | dsc config get
109+
dsc config get --file ./example.config.dsc.yaml
104110
```
105111

106112
```yaml
113+
metadata:
114+
Microsoft.DSC:
115+
version: 3.0.0
116+
operation: get
117+
executionType: actual
118+
startDatetime: 2025-02-24T16:09:40.671454400-06:00
119+
endDatetime: 2025-02-24T16:09:41.850086300-06:00
120+
duration: PT1.1786319S
121+
securityContext: restricted
107122
results:
108-
- name: example key value
123+
- metadata:
124+
Microsoft.DSC:
125+
duration: PT0.2751153S
126+
name: example key value
109127
type: Microsoft.Windows/Registry
110128
result:
111129
actualState:
112-
$id: https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json
113-
keyPath: ''
130+
keyPath: HKCU\example\key
131+
_exist: false
114132
messages: []
115133
hadErrors: false
116134
```
117135

118136
## Testing a configuration
119137

120-
The `dsc config test` command compares the current state of the resource instances to their desired state. The result for each instance includes:
138+
The `dsc config test` command compares the current state of the resource instances to their desired
139+
state. The result for each instance includes:
121140

122141
- The desired state for the instance.
123142
- The actual state of the instance.
124143
- Whether the instance is in the desired state.
125144
- The list of properties that are out of the desired state, if any.
126145

127-
DSC also collects any message emitted by the resources during the operation and indicates whether
128-
any of the resources raised an error.
146+
DSC also collects any message emitted by the resources during the operation, indicates whether any
147+
of the resources raised an error, and provides metadata about the operation as a whole and for each
148+
resource instance.
129149

130150
```sh
131-
cat ./example.config.dsc.yaml | dsc config test
151+
dsc config test --file /example.config.dsc.yaml
132152
```
133153

134154
```yaml
155+
metadata:
156+
Microsoft.DSC:
157+
version: 3.0.0
158+
operation: test
159+
executionType: actual
160+
startDatetime: 2025-02-24T16:11:42.798122500-06:00
161+
endDatetime: 2025-02-24T16:11:43.442216400-06:00
162+
duration: PT0.6440939S
163+
securityContext: restricted
135164
results:
136-
- name: example key value
165+
- metadata:
166+
Microsoft.DSC:
167+
duration: PT0.2234078S
168+
name: example key value
137169
type: Microsoft.Windows/Registry
138170
result:
139171
desiredState:
140-
valueData:
141-
String: This is an example.
142172
keyPath: HKCU\example\key
143173
valueName: Example
174+
valueData:
175+
String: This is an example.
144176
actualState:
145-
$id: https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json
146-
keyPath: ''
147-
_inDesiredState: false
177+
keyPath: HKCU\example\key
178+
_exist: false
148179
inDesiredState: false
149180
differingProperties:
150-
- valueData
151-
- keyPath
152181
- valueName
182+
- valueData
183+
- _exist
153184
messages: []
154185
hadErrors: false
155186
```
@@ -163,42 +194,56 @@ their desired state. The result for each instance includes:
163194
- The state of the instance after the operation.
164195
- Which properties the operation changed, if any.
165196

166-
DSC also collects any message emitted by the resources during the operation and indicates whether
167-
any of the resources raised an error.
197+
DSC also collects any message emitted by the resources during the operation, indicates whether any
198+
of the resources raised an error, and provides metadata about the operation as a whole and for each
199+
resource instance.
168200

169201
```sh
170-
cat ./example.config.dsc.yaml | dsc config set
202+
dsc config set --file ./example.config.dsc.yaml
171203
```
172204

173205
```yaml
206+
metadata:
207+
Microsoft.DSC:
208+
version: 3.0.0
209+
operation: set
210+
executionType: actual
211+
startDatetime: 2025-02-24T16:13:32.746742600-06:00
212+
endDatetime: 2025-02-24T16:13:33.606785-06:00
213+
duration: PT0.8600424S
214+
securityContext: restricted
174215
results:
175-
- name: example key value
216+
- metadata:
217+
Microsoft.DSC:
218+
duration: PT0.4070001S
219+
name: example key value
176220
type: Microsoft.Windows/Registry
177221
result:
178222
beforeState:
179-
$id: https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json
180-
keyPath: ''
223+
keyPath: HKCU\example\key
224+
_exist: false
181225
afterState:
182-
$id: https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json
183226
keyPath: HKCU\example\key
184227
valueName: Example
185228
valueData:
186229
String: This is an example.
187230
changedProperties:
188-
- keyPath
189231
- valueName
190232
- valueData
233+
- _exist
191234
messages: []
192235
hadErrors: false
193236
```
194237

195238
## See also
196239

197240
- [DSC Resources][01] to learn about resources.
198-
- [DSC Configuration document schema reference][03]
199-
- [Command line reference for the 'dsc config' command][04]
241+
- [DSC Configuration document schema reference][05]
242+
- [Command line reference for the 'dsc config' command][06]
200243

201244
[01]: ./resources.md
202-
[02]: ./resources.md#resource-type-names
245+
[02]: ../reference/schemas/config/metadata.md#microsoftdsc
203246
[03]: ../reference/schemas/config/document.md
204-
[04]: ../reference/cli/config/command.md
247+
[04]: ./resources.md#resource-type-names
248+
[05]: ../reference/schemas/config/document.md
249+
[06]: ../reference/cli/config/command.md

dsc/docs-conceptual/dsc-3.0/concepts/enhanced-authoring.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ description: >-
33
DSC configuration documents and resource manifests are YAML or JSON data files that adhere to a
44
published JSON schema. You can use enhanced schemas when authoring these files for an improved
55
experience.
6-
ms.date: 09/13/2023
6+
ms.date: 03/04/2025
77
title: Authoring with enhanced schemas
88
---
99

1010
# Authoring with enhanced schemas
1111

1212
Working with Microsoft's Desired State Configuration (DSC) platform involves writing DSC
1313
[configuration documents][01] and [resource manifests][02]. Configuration documents are YAML or
14-
JSON data files that declare the desired state of a system. Resource manifests are JSON data files
15-
that define a command-based DSC Resource.
14+
JSON data files that declare the desired state of a system. Resource manifests are JSON or YAML
15+
data files that define a DSC command resource.
1616

1717
DSC validates these data files with a JSON schema. While the schemas DSC uses for validation are
1818
useful for authoring configuration documents and resource manifests, Microsoft also defines a set
@@ -25,14 +25,21 @@ specific to VS Code that:
2525
- Add default snippets to autocomplete values.
2626

2727
> [!NOTE]
28-
> The enhanced schemas are non-canonical. Never specify them for the `$schema` keyword in a
29-
> configuration document or resource manifest. These schemas are only for improving the authoring
30-
> experience.
28+
> The enhanced schemas are non-canonical. Only specify them for the `$schema` keyword in a
29+
> configuration document or resource manifest when your tools support it.
30+
>
31+
> These schemas are only for improving the authoring experience. If you try to validate the
32+
> configuration document or resource manifest with a tool that doesn't support the extended
33+
> vocabulary, the tool may raise an error.
3134
>
3235
> The enhanced schemas share the same source definition as the canonical schemas and validate the
3336
> data in the same way. However, they include non-canonical keywords. For maximum compatibility
3437
> with other tools, the canonical schemas only use the core JSON schema vocabularies.
3538
39+
For the full list of recognized and supported schema URIs, including the enhanced authoring
40+
schemas, see the `$schema` sections in [DSC Configuration document schema reference][03] and
41+
[DSC resource manifest schema reference][04].
42+
3643
## Enhanced schema examples
3744

3845
### Example 1 - Documentation on hover
@@ -113,11 +120,11 @@ specific workspace.
113120
"**/*.dsc.json",
114121
"**/*.dsc.config.json"
115122
],
116-
"url": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/config/document.vscode.json"
123+
"url": "https://aka.ms/dsc/schemas/v3/bundled/config/document.vscode.json"
117124
}
118125
],
119126
"yaml.schemas": {
120-
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/config/document.vscode.json": "**.dsc.{yaml,yml,config.yaml,config.yml}"
127+
"https://aka.ms/dsc/schemas/v3/bundled/config/document.vscode.json": "**.dsc.{yaml,yml,config.yaml,config.yml}"
121128
}
122129
```
123130
<!-- markdownlint-enable MD013 -->
@@ -133,11 +140,11 @@ following suffixes:
133140
- `.dsc.yml`
134141

135142
To associate a specific configuration document formatted as YAML with the enhanced schema, add the
136-
following comment to the top of the configuration document:
143+
following comment to the top of the document:
137144

138145
<!-- markdownlint-disable MD013 -->
139146
```yml
140-
# yaml-language-server: $schema=https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/config/document.vscode.json
147+
# yaml-language-server: $schema=aka.ms/dsc/schemas/v3/bundled/config/document.vscode.json
141148
```
142149
<!-- markdownlint-enable MD013 -->
143150

@@ -155,12 +162,30 @@ specific workspace.
155162
```json
156163
"json.schemas": [
157164
{
158-
"fileMatch": ["**/*.dsc.resource.json"],
159-
"url": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.vscode.json"
165+
"fileMatch": ["**/*.dsc.resource.json", ],
166+
"url": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.vscode.json"
160167
}
161168
]
169+
"yaml.schemas": {
170+
"https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.vscode.json": "**.dsc.resource.{yaml,yml}"
171+
}
162172
```
163173
<!-- markdownlint-enable MD013 -->
164174

175+
To associate a specific resource manifest formatted as YAML with the enhanced schema, add the
176+
following comment to the top of the manifest:
177+
178+
<!-- markdownlint-disable MD013 -->
179+
```yml
180+
# yaml-language-server: $schema=https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.vscode.json
181+
```
182+
<!-- markdownlint-enable MD013 -->
183+
184+
This option works regardless of the filename, but only for YAML files. To use the enhanced schema
185+
when authoring resource manifests in JSON, you must define the schema association in your
186+
`settings.json`.
187+
165188
[01]: configurations.md
166189
[02]: ../resources/concepts/anatomy.md#dsc-resource-manifests
190+
[03]: ../reference/schemas/config/document.md#schema
191+
[04]: ../reference/schemas/resource/manifest/root.md#schema

0 commit comments

Comments
 (0)