Bylaw

Gallery › Security Center › Azure built-in policies

[Deprecated]: Configure supported Linux Arc machines to automatically install the Azure Security agent

Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.1.0-deprecated Deprecated

Configure supported Linux Arc machines to automatically install the Azure Security agent. Security Center collects events from the agent and uses them to provide security alerts and tailored hardening tasks (recommendations). Target Linux Arc machines must be in a supported location.

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

Azure Policy JSONASC_AzureSecurityLinuxAgent_Arc_DINE.json · 113 lines
{
  "properties": {
    "displayName": "[Deprecated]: Configure supported Linux Arc machines to automatically install the Azure Security agent",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Configure supported Linux Arc machines to automatically install the Azure Security agent. Security Center collects events from the agent and uses them to provide security alerts and tailored hardening tasks (recommendations). Target Linux Arc machines must be in a supported location.",
    "metadata": {
      "category": "Security Center",
      "version": "1.1.0-deprecated",
      "deprecated": true
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.HybridCompute/machines"
          },
          {
            "field": "Microsoft.HybridCompute/imageOffer",
            "like": "linux*"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.HybridCompute/machines/extensions",
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.HybridCompute/machines/extensions/type",
                "equals": "AzureSecurityLinuxAgent"
              },
              {
                "field": "Microsoft.HybridCompute/machines/extensions/Publisher",
                "equals": "Microsoft.Azure.Security.Monitoring"
              },
              {
                "field": "Microsoft.HybridCompute/machines/extensions/provisioningState",
                "equals": "Succeeded"
              }
            ]
          },
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/92aaf0da-9dab-42b6-94a3-d43ce8d16293"
          ],
          "deployment": {
            "properties": {
              "mode": "incremental",
              "parameters": {
                "location": {
                  "value": "[field('location')]"
                },
                "vmName": {
                  "value": "[field('name')]"
                }
              },
              "template": {
                "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                  "location": {
                    "type": "string"
                  },
                  "vmName": {
                    "type": "string"
                  }
                },
                "variables": {},
                "resources": [
                  {
                    "type": "Microsoft.HybridCompute/machines/extensions",
                    "name": "[concat(parameters('vmName'), '/', 'AzureSecurityLinuxAgent')]",
                    "apiVersion": "2021-06-10-preview",
                    "location": "[parameters('location')]",
                    "properties": {
                      "publisher": "Microsoft.Azure.Security.Monitoring",
                      "type": "AzureSecurityLinuxAgent",
                      "settings": {},
                      "protectedSettings": {}
                    }
                  }
                ]
              }
            }
          }
        }
      }
    },
    "versions": [
      "1.1.0",
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/2f47ec78-4301-4655-b78e-b29377030cdc",
  "name": "2f47ec78-4301-4655-b78e-b29377030cdc"
}
Bylaw2f47ec78-4301-4655-b78e-b29377030cdc.bylaw.ps1 · 40 lines
# Converted from ASC_AzureSecurityLinuxAgent_Arc_DINE.json by ConvertTo-Bylaw.
Policy '2f47ec78-4301-4655-b78e-b29377030cdc' {

    Properties @{
        DisplayName   = '[Deprecated]: Configure supported Linux Arc machines to automatically install the Azure Security agent'
        Description   = 'Configure supported Linux Arc machines to automatically install the Azure Security agent. Security Center collects events from the agent and uses them to provide security alerts and tailored hardening tasks (recommendations). Target Linux Arc machines must be in a supported location.'
        Category      = 'Security Center'
        Version       = '1.1.0-deprecated'
        Deprecated    = $true
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('DeployIfNotExists', 'Disabled')
        Default       = 'Disabled'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.HybridCompute/machines' {

        Require 'imageOffer is not like linux*' {
            Field 'Microsoft.HybridCompute/imageOffer' | Must -Not -BeLike 'linux*' -IfPresent
        }
    }

    DeployIfNotExists 'Microsoft.HybridCompute/machines/extensions' -Role 'Log Analytics Contributor' -Effect (Param Effect) {
        Require 'type, publisher and provisioningState are as required' {
            Field 'Microsoft.HybridCompute/machines/extensions/type' | Must -Be 'AzureSecurityLinuxAgent'
            Field publisher | Must -Be 'Microsoft.Azure.Security.Monitoring'
            Field provisioningState | Must -Be 'Succeeded'
        }
        Deployment -TemplateFile './templates/2f47ec78-4301-4655-b78e-b29377030cdc.json' -Parameters ([ordered]@{
                location = (Arm '[field(''location'')]')
                vmName   = (Arm '[field(''name'')]')
            })
    }
}

Its deployment templates are written beside it:

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