2017-10-20 15 views
1

私はカスタムDSCコンポジットリソースを作成して、誰かが光を当てることを望んでいたAzure Automationモジュールリストにアップロードすることに問題があります。今、もしAzure AutomationのカスタムPowerShell DSCコンポジットリソース

Configuration CompositeResource 
{ 
    Import-DscResource -ModuleName PSDesiredStateConfiguration 

    File ExampleFolder 
    { 
     DestinationPath = "C:\Example" 
     Type   = "Directory" 
    } 
} 

$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 '' 

そしてCompositeResource.schema.psm1ファイルで、私は次のコードを追加しました:私は、次のコードを実行することで、基本的なPowerShellのDSC複合リソースを作成しました私は、CompositeExample_1.0.zipとしてC:\ Program Files \ WindowsPowerShell \ Modules \ CompositeExampleフォルダを圧縮し、それを「クラシック」DSCサーバにアップロードして別の設定で参照しています。

しかし、私は(CompositeModule.zipとして)Azureのオートメーション内のモジュールとして追加する場合、私次のエラーを取得する:

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. 

モジュールは、Azureのための別の方法で「バンドル」する必要がありますか、追加のファイルが必要ですか?

答えて

0

問題は、私がルートモジュールマニフェストを作成するときに-RootModule行を指定することでした。 「Classic」DSCはそれを無視しているようですが、Azure Automationはファイルが存在しないためエラーを投げます。そう複合モジュールを作成するためのコードは

$parentModulePath = 'C:\Program Files\WindowsPowerShell\Modules\CompositeExample' 
mkdir $parentModulePath 
New-ModuleManifest –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 '' 

Azureの自動化は、これはエラーなしのモジュールとして追加されることを可能にするであろう。

関連する問題