Hi jeremyahagan,
Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
Issue: When you’re using Azure DSC (Desired State Configuration) to set up and secure your VMs, some steps require the VM to reboot. The Local Configuration Manager (LCM) is set to automatically reboot and continue the configuration after each reboot. However, the DSC extension doesn’t always recognize that the configuration is still in progress after the first reboot. The server might end up in an unstable state because both DSC and the Custom Script Extension are trying to make changes simultaneously. Multiple reboots can disrupt the Custom Script Extension’s execution, causing it to fail or produce unexpected results.
Suggested Workarounds: To avoid this, you need a way to ensure that the Custom Script Extension only runs after the DSC configuration is completely finished. This can be achieved by using coordination mechanisms like flag files, registry keys, or breaking down the DSC configuration into smaller, sequential steps.
1. Using Flag Files: You can create a flag file at the end of your DSC configuration to signal completion. The Custom Script Extension can then check for this file before proceeding.
https://learn.microsoft.com/en-us/powershell/dsc/reference/resources/windows/fileresource?view=dsc-1.1
2. Using Registry Keys: You can use the DSC Registry Resource to set a registry key once the configuration is complete. The Custom Script Extension can check this registry key before running. Documentation: https://learn.microsoft.com/en-us/powershell/dsc/reference/resources/windows/registryresource?view=dsc-1.1
3.Breaking Down DSC Configurations: Consider breaking down your DSC configuration into smaller, sequential steps. Each step can set a flag or registry key that the next step or the Custom Script Extension can check.
General DSC Documentation: https://learn.microsoft.com/en-us/powershell/dsc/reference/microsoft/windows/registry/overview?view=dsc-3.0
This article provides information about each version of the Azure DSC VM extension, what environments it supports, and comments and remarks on new features or changes.
https://learn.microsoft.com/en-us/azure/automation/automation-dsc-extension-history
If the above suggestion is helpful, please click "Upvote it."