Skip to content

Instantly share code, notes, and snippets.

@arcotek-ltd
Created February 21, 2018 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arcotek-ltd/0c58f74d1f67986c3a661f9eef849605 to your computer and use it in GitHub Desktop.
Save arcotek-ltd/0c58f74d1f67986c3a661f9eef849605 to your computer and use it in GitHub Desktop.
Reference AutomationAccount in Azure templates
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"dscConfigurationName": {
"type": "string",
"metadata": {
"description": "Name of DSC configuration to apply."
}
},
"dscConfigurationBaseUri": {
"type": "string",
"metadata": {
"description": "Name of DSC configuration."
}
},
"dscConfigurationParameters": {
"type": "object",
"metadata": {
"description": "Parameters required by the configuration, including ConfigurationData"
}
},
"compile": {
"type": "string",
"allowedValues": [
"Yes",
"No"
],
"metadata": {
"description": "Whether DSC is compiled or not."
}
}
},
"variables": {
"automationAccountResourceGroupName": "RG-S02-S-UIL-MRG-001",
"automationAccountName": "AA-UWC-DEV-004",
"automationAccountResourceId": "[resourceId(variables('automationAccountResourceGroupName'),'Microsoft.Automation/automationAccounts',variables('automationAccountName'))]",
"dscConfigurations": {
"monoConfig": {
"name": "[parameters('dscConfigurationName')]",
"description": "Configure Dynamics AX 2012R3",
"url": "[concat(parameters('dscConfigurationBaseUri'),'/',parameters('dscConfigurationName'),'/',parameters('dscConfigurationName'),'.ps1')]",
"compileName": "[guid(resourceGroup().id, deployment().name)]"
}
}
},
"resources": [
{
"condition": "[equals(parameters('compile'), 'Yes')]",
"apiVersion": "2017-05-10",
"name": "[concat('childTemplate-',variables('dscConfigurations').monoConfig.compileName)]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[variables('automationAccountResourceGroupName')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiversion": "2015-10-31",
"location": "[reference(variables('automationAccountResourceId'), '2017-05-15-preview','Full').location]",
"name": "[variables('automationAccountName')]",
"type": "Microsoft.Automation/automationAccounts",
"properties": {
"sku": {
"name": "Basic"
}
},
"tags": {
"testTag": "This is a test1"
},
"resources": [
{
"name": "[variables('dscConfigurations').monoConfig.name]",
"type": "configurations",
"apiVersion": "2015-01-01-preview",
"location": "[reference(variables('automationAccountResourceId'), '2017-05-15-preview','Full').location]",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', variables('AutomationAccountName'))]"
],
"properties": {
"state": "Published",
"overwrite": "true",
"Source": {
"type": "uri",
"value": "[variables('dscConfigurations').monoConfig.url]"
}
}
},
{
"name": "[variables('dscConfigurations').monoConfig.compileName]",
"type": "Compilationjobs",
"apiVersion": "2015-01-01-preview",
"tags": {},
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', variables('AutomationAccountName'))]",
"[concat('Microsoft.Automation/automationAccounts/', variables('AutomationAccountName'),'/Configurations/', variables('dscConfigurations').monoConfig.name)]"
],
"properties": {
"configuration": {
"name": "[variables('dscConfigurations').monoConfig.name]"
},
"parameters": "[parameters('dscConfigurationParameters')]"
}
}
]
}
]
},
"parameters": {}
}
}
],
"outputs": {
"output1": {
"type": "string",
"value": "[variables('dscConfigurations').monoConfig.name]"
},
"output2": {
"type": "string",
"value": "[variables('dscConfigurations').monoConfig.description]"
},
"output3": {
"type": "string",
"value": "[variables('dscConfigurations').monoConfig.url]"
},
"output4": {
"type": "string",
"value": "[variables('dscConfigurations').monoConfig.compileName]"
},
"Output5": {
"type": "string",
"value": "[if(equals(parameters('compile'), 'No'), 'Compile parameter set to No. Compilation has not been performed.','Compile parameter set to Yes. Compile complete.')]"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment