Skip to content

Commit 4cc1299

Browse files
authored
Create migrating-from-dsc-extension.md
1 parent e984fb2 commit 4cc1299

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
title: Planning a change from Desired State Configuration extension to machine configuration
3+
description: Guidance for moving from Desired State Configuration extension to Azure machine configuration.
4+
ms.date: 01/29/2025
5+
ms.topic: how-to
6+
---
7+
# Planning a change from Desired State Configuration extension to Azure machine configuration
8+
9+
Machine configuration is the latest implementation of functionality that has been provided by the
10+
PowerShell Desired State Configuration (DSC) extension for virtual machines in Azure. When
11+
possible, you should plan to move your content and machines to the new service. This article
12+
provides guidance on developing a migration strategy.
13+
14+
New features in machine configuration:
15+
16+
- Advanced reporting through Azure Resource Graph including resource ID and state
17+
- Manage multiple configurations for the same machine
18+
- When machines drift from the desired state, you control when remediation occurs
19+
20+
Before you begin, it's a good idea to read the conceptual overview information at the page
21+
[Azure Policy's machine configuration][01].
22+
23+
## Major differences
24+
25+
Configurations are deployed through the DSC extension in a "push" model, where the
26+
operation is completed asynchronously. The deployment doesn't return until the configuration has
27+
finished running inside the virtual machine. After deployment, no further information is returned
28+
to Resource Manager. The monitoring and drift are managed within the machine.
29+
30+
Machine configuration processes configurations in a "pull" model. The extension is deployed to a
31+
virtual machine and then jobs are executed based on machine configuration assignment details. It
32+
isn't possible to view the status while the configuration in real time as it's being applied inside
33+
the machine. It's possible to watch and correct drift from Azure Resource Manager after the
34+
configuration is applied.
35+
36+
The DSC extension included **privateSettings** where secrets could be passed to the configuration,
37+
such as passwords or shared keys. Secrets management hasn't yet been implemented for machine
38+
configuration.
39+
40+
### Considerations for whether to migrate existing machines or only new machines
41+
42+
Machine configuration uses DSC version 3 with PowerShell version 7. DSC version 3 can coexist with
43+
older versions of DSC. The implementations are separate. However, there's no
44+
conflict detection.
45+
46+
The zip file artifact used by DSC Extension is not compatible with Azure machine configuration.
47+
Plan to use the machine configuration authoring tools to repackage the configuration
48+
and required PowerShell modules and republish to Azure Storage.
49+
50+
Using both platforms to manage the same configuration isn't advised.
51+
52+
## Understand migration
53+
54+
The best approach to migration is to recreate, test, and redeploy content first, and then use the
55+
new solution for new machines.
56+
57+
The expected steps for migration are:
58+
59+
1. Download and expand the `.zip` package used for the DSC extension.
60+
1. Examine the Managed Object Format (MOF) file and resources to understand the scenario.
61+
1. Make any required changes to the configuration or resources.
62+
1. Use the machine configuration authoring module to create, test, and publish a new package.
63+
1. Use machine configuration for future deployments rather than DSC extension.
64+
65+
#### Consider decomposing complex configuration files
66+
67+
Machine configuration can manage multiple configurations per machine. Many configurations written
68+
for the DSC extension assumed the limitation of managing a single configuration per
69+
machine. To take advantage of the expanded capabilities offered by machine configuration, large
70+
configuration files can be divided into many smaller configurations where each handles a specific
71+
scenario.
72+
73+
There's no orchestration in machine configuration to control the order of how configurations are
74+
sorted. Keep steps in a configuration together in one package if they must happen sequentially.
75+
76+
### Test content in Azure machine configuration
77+
78+
Read the page [How to create custom machine configuration package artifacts][02] to evaluate
79+
whether your content from the DSC extension can be used with machine configuration.
80+
81+
When you reach the step [Author a configuration][03], use the MOF file from the DSC extension
82+
package as the basis for creating a new MOF file and custom DSC resources. You must have the custom
83+
PowerShell modules available in `$env:PSModulePath` before you can create a machine configuration
84+
package.
85+
86+
#### Update deployment templates
87+
88+
If your deployment templates include the DSC extension (see [examples][04]), there are two changes
89+
required.
90+
91+
First, replace the DSC extension with the [extension for the machine configuration feature][01].
92+
93+
Then, add a [machine configuration assignment][05] that associates the new configuration package
94+
(and hash value) with the machine.
95+
96+
#### Do I need to add the Reasons property to custom resources?
97+
98+
Implementing the [Reasons property][06] provides a better experience when viewing the results of
99+
a configuration assignment from the Azure portal. If the `Get` method in a module doesn't include
100+
**Reasons**, generic output is returned with details from the properties returned by the `Get`
101+
method. Therefore, it's optional for migration.
102+
103+
### Removing a configuration the DSC extension assigned
104+
105+
In previous versions of DSC, the DSC extension assigned a configuration through the Local
106+
Configuration Manager (LCM). It's recommended to remove the DSC extension and reset the LCM.
107+
108+
> [!IMPORTANT]
109+
> Removing a configuration in Local Configuration Manager doesn't "roll back" the settings
110+
> that were set by the configuration. The action of removing the configuration only causes the LCM
111+
> to stop managing the assigned configuration. The settings remain in place.
112+
113+
Use the `Remove-DscConfigurationDocument` command as documented in
114+
[Remove-DscConfigurationDocument][07]
115+
116+
## Next steps
117+
118+
- [Develop a custom machine configuration package][08].
119+
- Use the **GuestConfiguration** module to [create an Azure Policy definition][09] for at-scale
120+
management of your environment.
121+
- [Assign your custom policy definition][10] using Azure portal.
122+
123+
<!-- Reference link definitions -->
124+
[01]: ../overview.md
125+
[02]: ../how-to/develop-custom-package/2-create-package.md
126+
[03]: ../how-to/develop-custom-package/2-create-package.md#author-a-configuration
127+
[04]: /azure/virtual-machines/extensions/dsc-template
128+
[05]: ../concepts/assignments.md
129+
[06]: ./psdsc-in-machine-configuration.md#special-requirements-for-get
130+
[07]: /powershell/module/psdesiredstateconfiguration/remove-dscconfigurationdocument
131+
[08]: ../how-to/develop-custom-package/overview.md
132+
[09]: ../how-to/create-policy-definition.md
133+
[10]: ../../policy/assign-policy-portal.md

0 commit comments

Comments
 (0)