0
votes

I have created an ARM template which successfully creates an Automation Account in Azure and then creates a module and DSC configuration in that account.

When I add a Microsoft.Automation/automationAccounts/Compilationjobs resource to compile the DSC configuration, the template deployment fails at this step with 404 - File or directory not found.

The Compilationjobs resource exists as a top level resource in the template as follows:

 {
  "apiVersion": "2015-10-31",
  "type": "Microsoft.Automation/automationAccounts/Compilationjobs",
  "name": "automationAccountName/jobId123",
  "location": "[variables('location')]",
  "tags": {
  },
  "dependsOn": [
    "Microsoft.Automation/automationAccounts/automationAccountName",
    "modulesResourceLoop"
  ],
  "properties": {
    "configuration": {
      "name": "DSCConfigurationName"
    }
  }
}

When I call Start-AzureRmAutomationDscCompilationJob with the same details the compilation job is created and completes successfully.

1

1 Answers

0
votes

Compiling the configuration involves creating a compliationJob. Under the hood it's a PUT call to /CompiliationJobs/{guid}. so the trick here is to pass a new guid into the arm template when invoking compilation job.

Something like the following, you will need to define the parameter compilationJobGuid:

{
  "name": "[parameters('compilationJobGuid')]",
  "apiVersion": "2015-10-31",
  "type": "Microsoft.Automation/automationAccounts/Compilationjobs",
  "location": "[variables('location')]",
  "tags": {
  },
  "dependsOn": [
    "Microsoft.Automation/automationAccounts/automationAccountName",
    "modulesResourceLoop"
  ],
  "properties": {
    "configuration": {
      "name": "DSCConfigurationName"
    }
  }
}