Search code examples
azurepowershelldscazure-rm-template

No module found DSC extension on Azure Json


I am trying to run a DSC file during an installation, and it was working yesterday and tday I'm getting the error below:

       "code": "VMExtensionProvisioningError",
        "message": "VM has reported a failure when processing extension 'IIS2'. Error message: \"The DSC Extension received an incorrect input: An error occurred while executing script or module 'configuration':  
The specified module 'configuration' was not loaded because no valid module file was found in any module directory..\nPlease correct the input and retry executing the extension.\"."

I don't think anyone has messed with it, but I've spent hours trying to work out what the issue could be, was hoping to get some ideas, if anyoe can see anything I might have missed.

The DSC file is:

configuration IIS2
    {

    Import-DscResource -ModuleName xActiveDirectory, xStorage, xNetworking, PSDesiredStateConfiguration, xPendingReboot, xDnsServer

        Node localhost
        {
            LocalConfigurationManager
            {
                RebootNodeIfNeeded = $true
            }

            xWaitforDisk Disk2
            {
                DiskId = 2
                RetryIntervalSec =$RetryIntervalSec
                RetryCount = $RetryCount
            }

            xDisk ADDataDisk {
                DiskId = 2
                DriveLetter = "F"
                DependsOn = "[xWaitForDisk]Disk2"
            }

            WindowsFeature Failover-Clustering
            {
                Ensure = "Present"
                Name = "Failover-Clustering"
            }

            WindowsFeature Web-Server
            {
                Ensure = "Present"
                Name = "Web-Server"
            }

       }
    }

Solution

  • i think what its saying you are calling it as configuration and its actually called IIS2 (I mean from the ARM Template).

    {
        "name": "System_PowerShell_DSC",
        "properties": {
            "publisher": "Microsoft.Powershell",
            "type": "DSC",
            "typeHandlerVersion": "2.19",
            "autoUpgradeMinorVersion": true,
            "settings": {
                "configuration": {
                    "url": "url",
                    "script": "file-name.ps1",
                    "function": "function-name" # IIS2 in your case
                }
            },
            "protectedSettings": {
                "configurationArguments": {
                    "sfCert": {
                        "userName": "yyy",
                        "password": "xxx"
                    }
                }
            }
        }