{ "if": { "allOf": [ { "field": "type", "equals": "Microsoft.Compute/virtualMachines" }, { "field": "Microsoft.Compute/imageOffer", "equals": "WindowsServer" } ] }, "then": { "effect": "[parameters('effect')]", "details": { "type": "Microsoft.Compute/virtualMachines/extensions", "existenceCondition": { "allOf": [ { "field": "Microsoft.Compute/virtualMachines/extensions/type", "equals": "NetworkWatcherAgentWindows" } ] }, "roleDefinitionIds": [ "/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c" ], "deployment": { "properties": { "mode": "Incremental", "template": { "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "vmName": { "type": "String" }, "location": { "type": "String" } }, "resources": [ { "type": "Microsoft.Compute/virtualMachines/extensions", "apiVersion": "2015-06-15", "name": "[concat(parameters('vmName'),'/AzureNetworkWatcherExtension')]", "location": "[parameters('location')]", "properties": { "publisher": "Microsoft.Azure.NetworkWatcher", "type": "NetworkWatcherAgentWindows", "typeHandlerVersion": "1.4", "autoUpgradeMinorVersion": true, "settings": {} } } ], "outputs": { "policy": { "type": "string", "value": "[concat('Enabled NetworkWatcher for Windows VM', ': ', parameters('vmName'))]" } } }, "parameters": { "vmName": { "value": "[field('name')]" }, "location": { "value": "[field('location')]" } } } } } } }