ARM template for enabling Update Management on Azu

2019-08-23 22:46发布

问题:

Could someone help me to enable update management on Azure VM with Azure Resource Manager Template.

I could find any template online to enable it.

Reference: https://docs.microsoft.com/en-us/azure/automation/automation-update-management

回答1:

you cannot enable vm for update management, you can link oms and azure automation with update management enabled. more or less. here's a more or less working variant:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.1",
    "parameters": {
        "prefix": {
            "type": "string"
        }
    },
    "variables": {
        "namespace": "[concat(parameters('prefix'), '-la')]",
        "automation": "[concat(parameters('prefix'), '-aa')]",
        "solutions": [
            "AlertManagement",
            "Updates",
            "Security"
        ]
    },
    "resources": [
        {
            "type": "Microsoft.OperationalInsights/workspaces",
            "name": "[variables('namespace')]",
            "apiVersion": "2017-03-15-preview",
            "location": "[resourceGroup().location]",
            "properties": {
                "sku": {
                    "name": "Standalone"
                }
            },
            "resources": [
                {
                    "name": "Automation",
                    "type": "linkedServices",
                    "apiVersion": "2015-11-01-preview",
                    "dependsOn": [
                        "[variables('automation')]",
                        "[variables('namespace')]"
                    ],
                    "properties": {
                        "resourceId": "[resourceId('Microsoft.Automation/automationAccounts/', variables('automation'))]"
                    }
                },
            ]
        },
        {
            "type": "Microsoft.Automation/automationAccounts",
            "name": "[variables('automation')]",
            "apiVersion": "2015-10-31",
            "location": "[resourceGroup().location]",
            "properties": {
                "sku": {
                    "name": "OMS"
                }
            }
        },
        {
            "type": "Microsoft.OperationsManagement/solutions",
            "name": "[concat(variables('solutions')[copyIndex()],'(', variables('namespace'), ')')]",
            "apiVersion": "2015-11-01-preview",
            "location": "[resourceGroup().location]",
            "copy": {
                "name": "solutions",
                "count": "[length(variables('solutions'))]"
            },
            "plan": {
                "name": "[concat(variables('solutions')[copyIndex()], '(', variables('namespace'), ')')]",
                "promotionCode": "",
                "product": "[concat('OMSGallery/', variables('solutions')[copyIndex()])]",
                "publisher": "Microsoft"
            },
            "properties": {
                "workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', variables('namespace'))]"
            },
            "dependsOn": [
                "[variables('namespace')]"
            ]
        }
    ]
}


回答2:

I have just included the following script to my VM deployment script. Is it okay

{
        "type": "Microsoft.OperationsManagement/solutions",
        "name": "[concat(variables('solutions')[copyIndex()],'(', parameters('workspaceName'), ')')]",
        "apiVersion": "2015-11-01-preview",
        "location": "[resourceGroup().location]",
        "copy": {
            "name": "solutions",
            "count": "[length(variables('solutions'))]"
        },
        "plan": {
            "name": "[concat(variables('solutions')[copyIndex()], '(', parameters('workspaceName'), ')')]",
            "promotionCode": "",
            "product": "[concat('OMSGallery/', variables('solutions')[copyIndex()])]",
            "publisher": "Microsoft"
        },
        "properties": {
            "workspaceResourceId": "[reference(resourceId(parameters('workspaceRGName'), 'Microsoft.OperationalInsights/workspaces/', parameters('workspaceName')), '2015-03-20').customerId]"
        }
    }