Trying to add an extension arm template to our Windows VM deployments, and noticed it is failing to validate the extension template. The Network Watcher Arm template fails to deploy with the below error message. Not sure what I could be missing here. I tried following the schema, found here.
ERROR TYPE Deployment template validation failed: 'The template resource 'networkWatcherAgent' for type 'Microsoft.Compute/virtualMachines/extensions' at line '24' and column '64' has incorrect segment lengths. A nested resource type must have identical number of segments as its resource name. A root resource type must have segment length one greater than its resource name. Please see https://aka.ms/arm-syntax-resources for usage details.'. (Code: InvalidTemplate)
Arm template:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
}
},
"variables": {
"apiVersion": "2022-11-01"
},
"resources": [
{
"name": "networkWatcherAgent",
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "[variables('apiVersion')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]"
],
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.Azure.NetworkWatcher",
"type": "NetworkWatcherAgentWindows",
"typeHandlerVersion": "1.4"
}
}
]
}
There might be a misunderstanding in the template structure; the dependency on
Microsoft.Compute/virtualMachinesmight be causing issue.Here is the updated
ARMtemplate to create aNetwork Watcher Agentextension in an existingWindows VM.Output