Add module in Azure Automation if DSC Configuration compilation fails

If you get the following error, see below, when compiling DSC Configuration in Azure Automation, it is probably because the module for the DSC Configuration is missing. In my example I need the “nx” module to compile the DSC configuration file. To solve the problem, add the module to the Azure Automation account.

Add module in Azure Automation if DSC Configuration compilation fails 1

Exception calling “NewScriptBlock” with “1” argument(s): “At line:4 char:5 + Import-DSCResource -Module nx + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The DSC engine could not load the module ‘nx’. It was not found on the system. At line:8 char:9 + nxPackage apache2Install + ~~~~~~~~~ Undefined DSC resource ‘nxPackage’. Use Import-DSCResource to import the resource. At line:15 char:9 + nxService apache2Service + ~~~~~~~~~ Undefined DSC resource ‘nxService’. Use Import-DSCResource to import the resource. At line:23 char:9 + nxFile apache2File + ~~~~~~ Undefined DSC resource ‘nxFile’. Use Import-DSCResource to import the resource.” (At line:4 char:5 + Import-DSCResource -Module nx + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The DSC engine could not load the module ‘nx’. It was not found on the system. At line:8 char:9 + nxPackage apache2Install + ~~~~~~~~~ Undefined DSC resource ‘nxPackage’. Use Import-DSCResource to import the resource. At line:15 char:9 + nxService apache2Service + ~~~~~~~~~ Undefined DSC resource ‘nxService’. Use Import-DSCResource to import the resource. At line:23 char:9 + nxFile apache2File + ~~~~~~ Undefined DSC resource ‘nxFile’. Use Import-DSCResource to import the resource.)

Add Module

Open the Azure Automation account and click Asset and then Modules.

Add module in Azure Automation if DSC Configuration compilation fails2

If you have a module package you can upload it to Azure Automation by clicking “Add a module” if it exists in the Gallery, you can download and install it from there. In my example I will click “Browse Gallery” and install it from there.

Add module in Azure Automation if DSC Configuration compilation fails3

Search for the module to install. In my example “nx”.

Add module in Azure Automation if DSC Configuration compilation fails4

Click the module to install and then “Import”.

Add module in Azure Automation if DSC Configuration compilation fails5

Now the module should be installed into the Azure Automation account and be ready to use.

Add module in Azure Automation if DSC Configuration compilation fails6

Try to compile the DSC Configuration file again to see if it works!

 

 

No comments yet.

Leave a Reply