Skip to content

Commit dfa3d4f

Browse files
Merge pull request #293831 from mgreenegit/patch-13
Create migrating-from-dsc-extension.md
2 parents c258476 + 5855c01 commit dfa3d4f

File tree

4 files changed

+141
-6
lines changed

4 files changed

+141
-6
lines changed

.openpublishing.redirection.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,11 +1180,6 @@
11801180
"redirect_url": "/azure/api-management/monitor-api-management",
11811181
"redirect_document_id": false
11821182
},
1183-
{
1184-
"source_path_from_root": "/articles/governance/machine-configuration/whats-new/migrating-from-dsc-extension.md ",
1185-
"redirect_url": " https://azure.microsoft.com/updates/migrate-from-linux-dsc-extension-to-the-guest-configuration-feature-of-azure-policy-by-may-1-2025/",
1186-
"redirect_document_id": false
1187-
},
11881183
{
11891184
"source_path_from_root": "/articles/vpn-gateway/vpn-gateway-about-forced-tunneling.md",
11901185
"redirect_url": "/previous-versions/azure/vpn-gateway/vpn-gateway-about-forced-tunneling",

articles/governance/machine-configuration/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ items:
2424
href: ./whats-new/docs.md
2525
- name: Migrating from Azure Automation DSC
2626
href: ./whats-new/migrating-from-azure-automation.md
27+
- name: Migrating from Azure DSC Extension
28+
href: ./whats-new/migrating-from-dsc-extension.md
2729
- name: Behavioral changes for PowerShell DSC
2830
href: ./whats-new/psdsc-in-machine-configuration.md
2931

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

articles/governance/machine-configuration/whats-new/psdsc-in-machine-configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Before you begin, it's a good idea to read the overview of [machine configuratio
1111

1212
[A video walk-through of this document is available][02].
1313

14-
Machine configuration uses [PowerShell Desired State Configuration (PSDSC)][03] version 3 to audit
14+
Machine configuration uses [PowerShell Desired State Configuration (PSDSC)][03] version 2 to audit
1515
and configure machines. The DSC configuration defines the state that the machine should be in.
1616
There's many notable differences in how DSC is implemented in machine configuration.
1717

0 commit comments

Comments
 (0)