last sync: 2021-Sep-24 16:09:49 UTC

Azure Policy definition

Deploy Dependency agent for Linux virtual machines

Name Deploy Dependency agent for Linux virtual machines
Azure Portal
Id 4da21710-ce6f-4e06-8cdb-5cc4c93ffbee
Version 1.3.0
details on versioning
Category Monitoring
Microsoft docs
Description Deploy Dependency agent for Linux virtual machines if the VM Image (OS) is in the list defined and the agent is not installed.
Mode Indexed
Type BuiltIn
Preview FALSE
Deprecated FALSE
Effect Fixed: deployIfNotExists
Used RBAC Role
Role Name Role Id
Log Analytics Contributor 92aaf0da-9dab-42b6-94a3-d43ce8d16293
History
Date/Time (UTC ymd) (i) Change type Change detail
2020-06-22 16:06:25 change Previous DisplayName: Deploy Dependency agent for Linux VMs
2020-04-22 04:43:16 change Previous DisplayName: [Preview]: Deploy Dependency Agent for Linux VMs
Used in Initiatives
Initiative DisplayName Initiative Id Initiative Category State
Enable Azure Monitor for VMs 55f3eceb-5573-4f18-9695-226972c6d74a Monitoring GA
JSON
{
  "displayName": "Deploy Dependency agent for Linux virtual machines",
  "policyType": "BuiltIn",
  "mode": "Indexed",
  "description": "Deploy Dependency agent for Linux virtual machines if the VM Image (OS) is in the list defined and the agent is not installed.",
  "metadata": {
    "version": "1.3.0",
    "category": "Monitoring"
  },
  "parameters": {
    "listOfImageIdToInclude": {
      "type": "Array",
      "metadata": {
        "displayName": "Optional: List of VM images that have supported Linux OS to add to scope",
        "description": "Example value: '/subscriptions//resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage'"
      },
      "defaultValue": []
    }
  },
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.Compute/virtualMachines"
        },
        {
          "anyOf": [
            {
              "field": "Microsoft.Compute/imageId",
              "in": "[parameters('listOfImageIdToInclude')]"
            },
            {
              "allOf": [
                {
                  "field": "Microsoft.Compute/imagePublisher",
                  "equals": "Canonical"
                },
                {
                  "field": "Microsoft.Compute/imageOffer",
                  "equals": "UbuntuServer"
                },
                {
                  "anyOf": [
                    {
                      "field": "Microsoft.Compute/imageSKU",
                      "in": [
                        "14.04.0-LTS",
                        "14.04.1-LTS",
                        "14.04.5-LTS"
                      ]
                    },
                    {
                      "field": "Microsoft.Compute/imageSKU",
                      "in": [
                        "16.04-LTS",
                        "16.04.0-LTS"
                      ]
                    },
                    {
                      "field": "Microsoft.Compute/imageSKU",
                      "in": [
                        "18.04-LTS"
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "allOf": [
                {
                  "field": "Microsoft.Compute/imagePublisher",
                  "equals": "RedHat"
                },
                {
                  "field": "Microsoft.Compute/imageOffer",
                  "in": [
                    "RHEL",
                    "RHEL-SAP-HANA"
                  ]
                },
                {
                  "anyOf": [
                    {
                      "field": "Microsoft.Compute/imageSKU",
                      "like": "6.*"
                    },
                    {
                      "field": "Microsoft.Compute/imageSKU",
                      "like": "7*"
                    }
                  ]
                }
              ]
            },
            {
              "allOf": [
                {
                  "field": "Microsoft.Compute/imagePublisher",
                  "equals": "SUSE"
                },
                {
                  "field": "Microsoft.Compute/imageOffer",
                  "in": [
                    "SLES",
                    "SLES-HPC",
                    "SLES-HPC-Priority",
                    "SLES-SAP",
                    "SLES-SAP-BYOS",
                    "SLES-Priority",
                    "SLES-BYOS",
                    "SLES-SAPCAL",
                    "SLES-Standard"
                  ]
                },
                {
                  "anyOf": [
                    {
                      "field": "Microsoft.Compute/imageSKU",
                      "in": [
                        "12-SP2",
                        "12-SP3",
                        "12-SP4"
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "allOf": [
                {
                  "field": "Microsoft.Compute/imagePublisher",
                  "equals": "OpenLogic"
                },
                {
                  "field": "Microsoft.Compute/imageOffer",
                  "in": [
                    "CentOS",
                    "Centos-LVM",
                    "CentOS-SRIOV"
                  ]
                },
                {
                  "anyOf": [
                    {
                      "field": "Microsoft.Compute/imageSKU",
                      "like": "6.*"
                    },
                    {
                      "field": "Microsoft.Compute/imageSKU",
                      "like": "7*"
                    }
                  ]
                }
              ]
            },
            {
              "allOf": [
                {
                  "field": "Microsoft.Compute/imagePublisher",
                  "equals": "cloudera"
                },
                {
                  "field": "Microsoft.Compute/imageOffer",
                  "equals": "cloudera-centos-os"
                },
                {
                  "field": "Microsoft.Compute/imageSKU",
                  "like": "7*"
                }
              ]
            }
          ]
        }
      ]
    },
    "then": {
      "effect": "deployIfNotExists",
      "details": {
        "type": "Microsoft.Compute/virtualMachines/extensions",
        "roleDefinitionIds": [
          "/providers/microsoft.authorization/roleDefinitions/92aaf0da-9dab-42b6-94a3-d43ce8d16293"
        ],
        "existenceCondition": {
          "allOf": [
            {
              "field": "Microsoft.Compute/virtualMachines/extensions/type",
              "equals": "DependencyAgentLinux"
            },
            {
              "field": "Microsoft.Compute/virtualMachines/extensions/publisher",
              "equals": "Microsoft.Azure.Monitoring.DependencyAgent"
            },
            {
              "field": "Microsoft.Compute/virtualMachines/extensions/provisioningState",
              "equals": "Succeeded"
            }
          ]
        },
        "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"
                }
              },
              "variables": {
                "vmExtensionName": "DependencyAgentLinux",
                "vmExtensionPublisher": "Microsoft.Azure.Monitoring.DependencyAgent",
                "vmExtensionType": "DependencyAgentLinux",
                "vmExtensionTypeHandlerVersion": "9.6"
              },
              "resources": [
                {
                  "type": "Microsoft.Compute/virtualMachines/extensions",
                  "name": "[concat(parameters('vmName'), '/', variables('vmExtensionName'))]",
                  "apiVersion": "2018-06-01",
                  "location": "[parameters('location')]",
                  "properties": {
                    "publisher": "[variables('vmExtensionPublisher')]",
                    "type": "[variables('vmExtensionType')]",
                    "typeHandlerVersion": "[variables('vmExtensionTypeHandlerVersion')]",
                    "autoUpgradeMinorVersion": true
                  }
                }
              ],
              "outputs": {
                "policy": {
                  "type": "string",
                  "value": "[concat('Enabled extension for VM', ': ', parameters('vmName'))]"
                }
              }
            },
            "parameters": {
              "vmName": {
                "value": "[field('name')]"
              },
              "location": {
                "value": "[field('location')]"
              }
            }
          }
        }
      }
    }
  }
}