Bylaw

Gallery › Security Center › Azure built-in policies

Setup subscriptions to transition to an alternative vulnerability assessment solution

Converted Policy DeployIfNotExists Disabled Mode All Version 1.0.0-preview

Microsoft Defender for cloud offers vulnerability scanning for your machines at no extra cost. Enabling this policy will cause Defender for Cloud to automatically propagate the findings from the built-in Microsoft Defender vulnerability management solution to all supported machines.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONASC_VulnerabilityAssessmentsSettings_DINE.json · 99 lines
{
  "properties": {
    "displayName": "Setup subscriptions to transition to an alternative vulnerability assessment solution",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Microsoft Defender for cloud offers vulnerability scanning for your machines at no extra cost. Enabling this policy will cause Defender for Cloud to automatically propagate the findings from the built-in Microsoft Defender vulnerability management solution to all supported machines.",
    "version": "1.0.0-preview",
    "metadata": {
      "category": "Security Center",
      "version": "1.0.0-preview"
    },
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "defaultValue": "DeployIfNotExists"
      },
      "selectedProvider": {
        "type": "String",
        "metadata": {
          "displayName": "Slected Vulnerability Assessment provider",
          "description": "Select the vulnerability assessment solution to provision to machines."
        },
        "allowedValues": [
          "MdeTvm"
        ],
        "defaultValue": "MdeTvm"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Resources/subscriptions"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/serverVulnerabilityAssessmentsSettings",
          "name": "AzureServersSetting",
          "existenceScope": "subscription",
          "deploymentScope": "subscription",
          "existenceCondition": {
            "field": "Microsoft.Security/serverVulnerabilityAssessmentsSettings/AzureServersSetting.selectedProvider",
            "equals": "MdeTvm"
          },
          "deployment": {
            "location": "eastus",
            "properties": {
              "mode": "Incremental",
              "template": {
                "contentVersion": "1.0.0.0",
                "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
                "parameters": {
                  "selectedProvider": {
                    "type": "string"
                  }
                },
                "variables": {
                  "settingsKind": "AzureServersSetting"
                },
                "resources": [
                  {
                    "type": "Microsoft.Security/serverVulnerabilityAssessmentsSettings",
                    "apiVersion": "2023-05-01",
                    "name": "[variables('settingsKind')]",
                    "kind": "[variables('settingsKind')]",
                    "properties": {
                      "selectedProvider": "[parameters('selectedProvider')]"
                    }
                  }
                ]
              },
              "parameters": {
                "selectedProvider": {
                  "value": "[parameters('selectedProvider')]"
                }
              }
            }
          },
          "roleDefinitionIds": [
            "/providers/Microsoft.Authorization/roleDefinitions/fb1c8493-542b-48eb-b624-b4c8fea62acd"
          ]
        }
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/766e621d-ba95-4e43-a6f2-e945db3d7888",
  "name": "766e621d-ba95-4e43-a6f2-e945db3d7888"
}
Bylaw766e621d-ba95-4e43-a6f2-e945db3d7888.bylaw.ps1 · 41 lines
# Converted from ASC_VulnerabilityAssessmentsSettings_DINE.json by ConvertTo-Bylaw.
Policy '766e621d-ba95-4e43-a6f2-e945db3d7888' {

    Properties @{
        DisplayName   = 'Setup subscriptions to transition to an alternative vulnerability assessment solution'
        Description   = 'Microsoft Defender for cloud offers vulnerability scanning for your machines at no extra cost. Enabling this policy will cause Defender for Cloud to automatically propagate the findings from the built-in Microsoft Defender vulnerability management solution to all supported machines.'
        Category      = 'Security Center'
        Version       = '1.0.0-preview'
        PolicyVersion = '1.0.0-preview'
        Mode          = 'All'
    }

    Parameter Effect @{
        AllowedValues = @('DeployIfNotExists', 'Disabled')
        Default       = 'DeployIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter SelectedProvider @{
        AllowedValues = @('MdeTvm')
        Default       = 'MdeTvm'
        DisplayName   = 'Slected Vulnerability Assessment provider'
        Description   = 'Select the vulnerability assessment solution to provision to machines.'
    }

    Resource 'Microsoft.Resources/subscriptions'

    DeployIfNotExists 'Microsoft.Security/serverVulnerabilityAssessmentsSettings' -Role 'Security Admin' -Name 'AzureServersSetting' -ExistenceScope Subscription -Effect (Param Effect) {
        Require 'AzureServersSetting.selectedProvider is MdeTvm' {
            Field AzureServersSetting.selectedProvider | Must -Be 'MdeTvm'
        }
        Deployment @{
            TemplateFile = './templates/766e621d-ba95-4e43-a6f2-e945db3d7888.json'
            Scope        = 'Subscription'
            Location     = 'eastus'
            Parameters   = [ordered]@{
                selectedProvider = (Param SelectedProvider)
            }
        }
    }
}

Its deployment templates are written beside it:

Source: built-in-policies/policyDefinitions/Security Center/ASC_VulnerabilityAssessmentsSettings_DINE.json in Azure/azure-policy, under the MIT licence.