I'm having problems creating a custom DSC composite resource and getting it uploaded into a Azure Automation module list that I was hoping someone could shed some light on. I've created a basic PowerShell DSC composite resource by executing the following code:
$parentModulePath = 'C:\Program Files\WindowsPowerShell\Modules\CompositeExample'
mkdir $parentModulePath
New-ModuleManifest -RootModule CompositeExample –Path "$parentModulePath\CompositeExample.psd1"
$resourceModulePath = "$parentModulePath\DSCResources\CompositeResource"
mkdir $resourceModulePath
New-ModuleManifest -RootModule 'CompositeResource.schema.psm1' –Path "$resourceModulePath\CompositeResource.psd1"
Add-Content –Path "$resourceModulePath\CompositeResource.schema.psm1" –Value ''
And then in the CompositeResource.schema.psm1 file I've added the following code:
Configuration CompositeResource
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
File ExampleFolder
{
DestinationPath = "C:\Example"
Type = "Directory"
}
}
Now if I zip up the C:\Program Files\WindowsPowerShell\Modules\CompositeExample folder as CompositeExample_1.0.zip and upload it to a 'classic' DSC server and reference it in a separate configuration it works perfectly fine.
However, if I add it as a module in Azure Automation (as CompositeModule.zip) I get the following error:
Error importing the module CompositeExample. Import failed with the following error:
Orchestrator.Shared.AsyncModuleImport.ModuleImportException: An error occurred during
module validation. When importing the module to an internal PowerShell session, it was not
able to be loaded by PowerShell. There is likely an issue with the contents of the module
that results in PowerShell's not being able to load it. Please verify that the module
imports successfully in a local PowerShell session, correct any issues, and then try
importing again.
Do modules need to be 'bundled' in a different way for Azure, or require additional files?