Azure DSC Configuration from Runbooks

453 views Asked by At

I have the following Workflow script as a Runbook on my Azure Automation account:

workflow Configure-VM
{
    $DSCConfigPath = "C:\DSCConfigs\TestConfiguration"
    inlinescript
    {
        Import-Module PSDesiredStateConfiguration
        Configuration TestConfiguration
        {
            Node "ak-testvm-001" {
                WindowsFeature IIS {
                    Ensure = "Present"
                    Name = "Web-Server"
                }
            }
        }

        Write-Output "INFO: Creating the DSC Configuration"
        TestConfiguration -NodeName "ak-testvm-001" -OutputPath $Using:DSCConfigPath

        Write-Output "INFO: Deploying DSC Configuration"
        Start-DscConfiguration -Path $Using:DSCConfigPath -Force -Wait -Verbose
        Write-Output "INFO: DSC Configuration Finished"

        Write-Output "INFO: END OF RUNBOOK"
    }
}

I get the following error when I run this RunBook:

Import-Module: The specified module 'PSDesiredStateConfiguration' was not loaded because it was not found in any module directory.

How can I run a DSC Configuration from Azure Runbooks? Is it even possible or do I absolutely need to use the Windows PowerShell?

1

There are 1 answers

0
Joe On

PowerShell Desired State Configuration support was added to Azure Automation in limited preview in May. You can read more on how to manage DSC nodes using Azure Automation here.