|
| 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 |
0 commit comments