I am going to use ARM templates to configure Update Management service in Azure. I dont want to deploy Update Management from the scratch, I would like to create Update Deployment and schedule a patching using ARM. I created teml file and param file, please see below. I am using script to deploy json file, presented below as well. I am facing an error like: New-AzureRmDeployment : 11:14:04 AM - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The resource 'Microsoft.Automation/automationAccounts/UpdateTesting' is not defined
in the template. Please see https://aka.ms/arm-template for usage details.'.
Template file:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"automationAccounts_UpdateTesting_name": {
"type": "String"
}
},
"variables": {},
"resources": [ {
"type": "Microsoft.Automation/automationAccounts/schedules",
"apiVersion": "2015-10-31",
"name": "[concat(parameters('automationAccounts_UpdateTesting_name'), '/testfromarm')]",
"dependsOn": [
"[resourceId('Microsoft.Automation/automationAccounts', parameters('automationAccounts_UpdateTesting_name'))]"
],
"properties": {
"startTime": "2020-03-10T10:57:00+01:00",
"expiryTime": "2020-03-10T10:57:00+01:00",
"frequency": "OneTime",
"timeZone": "Europe/Warsaw"
}
},
{
"type": "Microsoft.Automation/automationAccounts/softwareUpdateConfigurations",
"apiVersion": "2017-05-15-preview",
"name": "[concat(parameters('automationAccounts_UpdateTesting_name'), '/testfromarm')]",
"dependsOn": [
"[resourceId('Microsoft.Automation/automationAccounts', parameters('automationAccounts_UpdateTesting_name'))]"
],
"properties": {
"updateConfiguration": {
"operatingSystem": "Windows",
"windows": {
"includedUpdateClassifications": "Critical, Security, UpdateRollup, Updates",
"rebootSetting": "IfRequired"
},
"targets": {
"azureQueries": [
{
"scope": [
"/subscriptions/xxx"
],
"tagSettings": {
"tags": {
"PatchGroup": [
"group01"
]
},
"filterOperator": "All"
},
"locations": []
},
{
"scope": [
"/subscriptions/xxx"
],
"tagSettings": {
"tags": {
"PatchGroup": [
"group02"
]
},
"filterOperator": "All"
},
"locations": []
}
]
},
"duration": "PT2H"
},
"tasks": {},
"scheduleInfo": {}
}
}
],
"outputs": {}
}
Param file:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"automationAccounts_UpdateTesting_name": {
"value": "UpdateTesting"
}
}
}
Deployment script:
param(
[Parameter(Mandatory=$true)]
[string] $TemplateFilePath,
[Parameter(Mandatory=$true)]
[string] $TemplateParameterFilePath,
[Parameter(Mandatory=$true)]
[string] $DeploymentName,
[Parameter(Mandatory=$true)]
[string] $Location
)
$ErrorActionPreference = "Stop"
if ((Test-Path $TemplateFilePath) -and (Test-Path $TemplateParameterFilePath)) {
New-AzureRmDeployment -Location $Location -Name $DeploymentName -TemplateFile $TemplateFilePath -TemplateParameterFile $TemplateParameterFilePath
} else {
Write-Error "One of required files was not found"
}
I used following link to create json template file: softwareUpdateConfigurations, and used below presented ps1 script to run template and param file:
powershell script to run a template:
param(
[Parameter(Mandatory=$true)]
[string] $ResourceGroupName,
[Parameter(Mandatory=$true)]
[string] $TemplateFilePath,
[Parameter(Mandatory=$true)]
[string] $TemplateParameterFilePath
)
if((Test-Path $TemplateFilePath) -and (Test-Path $TemplateParameterFilePath)) {
New-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName -TemplateFile $TemplateFilePath -TemplateParameterFile $TemplateParameterFilePath
} else {
Write-Error "One of required files was not found."
}
Parameters file:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"automationAccounts_name": {
"value": "xxx"
},
"location": {
"value": "xxx"
},
"scheduleName1": {
"value": "xxx"
}
}
}