{
  "properties": {
    "displayName": "Configure machines to receive a vulnerability assessment agent",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Azure Defender includes vulnerability scanning for your machines at no extra cost. You don't need a Qualys license or even a Qualys account - everything's handled seamlessly inside Security Center. When you enable this policy, Azure Defender automatically deploys the Qualys vulnerability assessment agent to all supported machines that don't already have it installed.",
    "metadata": {
      "category": "Security Center", 
      "preview": true,
      "version": "2.1.0-preview"
    },
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "defaultValue": "DeployIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "in": [
          "Microsoft.Compute/virtualMachines",
          "Microsoft.HybridCompute/machines"
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/assessments",
          "name": "ffff0522-1e88-47fc-8382-2a80ba848f5d",
          "existenceCondition": {
            "field": "Microsoft.Security/assessments/status.code",
            "in": [
              "NotApplicable",
              "Healthy"
            ]
          },
          "deployment": {
            "properties": {
              "mode": "Incremental",
              "template": {
                "contentVersion": "1.0.0.0",
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "parameters": {
                  "vmName": {
                    "type": "String"
                  },
                  "resourceType": {
                    "type": "string"
                  }
                },
                "resources": [
                  {
                    "condition": "[equals(toLower(parameters('resourceType')), toLower('microsoft.compute/virtualmachines'))]",
                    "type": "Microsoft.Compute/virtualMachines/providers/serverVulnerabilityAssessments",
                    "name": "[concat(parameters('vmName'), '/Microsoft.Security/default')]",
                    "apiVersion": "2020-01-01"
                  },
                  {
                    "condition": "[equals(toLower(parameters('resourceType')), toLower('microsoft.hybridcompute/machines'))]",
                    "type": "Microsoft.HybridCompute/machines/providers/serverVulnerabilityAssessments",
                    "name": "[concat(parameters('vmName'), '/Microsoft.Security/default')]",
                    "apiVersion": "2020-01-01"
                  }
                ]
              },
              "parameters": {
                "vmName": {
                  "value": "[field('name')]"
                },
                "resourceType": {
                  "value": "[field('type')]"
                }
              }
            }
          },
          "roleDefinitionIds": [
            "/providers/Microsoft.Authorization/roleDefinitions/fb1c8493-542b-48eb-b624-b4c8fea62acd"
          ]
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/13ce0167-8ca6-4048-8e6b-f996402e3c1b",
  "name": "13ce0167-8ca6-4048-8e6b-f996402e3c1b"
}