Azure ARM-更新管理-VM入门

时间:2020-04-23 14:48:54

标签: azure azure-resource-manager azure-powershell azure-automation azure-log-analytics

我已经为VM进入Update Management准备了模板,这些模板是ARM涵盖的任务:MMA代理安装,将VM连接到工作区。 ARM可以正常工作,但是部署后还有一项任务要做,我必须在Update Management控制台中手动启用VM。我知道我可以在“管理机器”部分中启用自动启用功能,但是我想控制VM,并决定是否启用哪些VM。我的模板如下所示,有什么方法可以使用ARM模板将VM完全集成到Update Management中?

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "vmName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "List of virtual machines to be Lg Analytics Joined joined, if using multiple VMs, make their names comma separate. E.g. VM01, VM02, VM03."
            },
            "defaultValue": "VM1,VM2"
        },
        "Location":{
            "type": "string",
            "metadata": {
                "description": "Location of the VM"
            },
            "defaultvalue": "WestEurope"
        },

        "OMSWorkspaceResourceGroup":{
            "type": "string",
            "metadata": {
                "description": "OMSWorkspace RESOURCE GROUP"
            },
            "defaultvalue": "yourLogAnalyticsRG"
        },
        "omsWorkspacename": {
            "type": "string",
            "metadata": {
                "description": "OMSWorkspaceName"
            },
            "defaultvalue": "YourLoganalyticsworkspacename"
        }
    },
    "variables": {

        "vmListArray": "[split(parameters('vmName'),',')]"
    },
    "resources": [
        {
            "comments": "LogAnalyticsExtention",
            "apiVersion": "2019-07-01",
            "location": "[parameters('Location')]",
            "type": "Microsoft.Compute/virtualMachines/extensions",
            "name": "[concat(trim(variables('vmListArray')[copyIndex()]),'/MicrosoftMonitoringAgent')]",
            "copy": {
                "name": "ExtentionLooptoAllVMs",
                "count": "[length(variables('vmListArray'))]"
            },
            "properties": {
                "publisher": "Microsoft.EnterpriseCloud.Monitoring",
        "type": "MicrosoftMonitoringAgent",
        "typeHandlerVersion": "1.0",
        "autoUpgradeMinorVersion": true,
                "settings": {
                    "workspaceId": "[reference(resourceId(parameters('OMSWorkspaceResourceGroup'), 'Microsoft.OperationalInsights/workspaces/', parameters('omsWorkspacename')), '2015-11-01-preview').customerId]"
                },
                "protectedSettings": {
                    "workspaceKey": "[listKeys(resourceId(parameters('OMSWorkspaceResourceGroup'),'Microsoft.OperationalInsights/workspaces/', parameters('omsWorkspacename')),'2015-11-01-preview').primarySharedKey]"
                }
            }
        }
    ]
}

2 个答案:

答案 0 :(得分:1)

This文档的模板具有下面提到的前4个步骤,但总的来说,等效于您的需求(如在门户网站中一样):

  1. 创建Log Analytics工作区。 ARM参考:https://docs.microsoft.com/azure/templates/microsoft.operationalinsights/2015-11-01-preview/workspaces
  2. 创建自动化帐户。 ARM参考:https://docs.microsoft.com/azure/templates/microsoft.automation/2015-10-31/automationaccounts
  3. 链接自动化帐户和Log Analytics工作区。 ARM参考:https://docs.microsoft.com/azure/templates/microsoft.operationalinsights/2015-11-01-preview/workspaces/linkedservices
  4. 安装OMS / LA解决方案,例如更新管理。 ARM参考:https://docs.microsoft.com/azure/templates/microsoft.operationsmanagement/2015-11-01-preview/solutions
  5. 通过VM扩展
  6. 将机器加载到OMS / LA解决方案。 ARM参考:https://docs.microsoft.com/azure/templates/microsoft.compute/2019-07-01/virtualmachines/extensions 还可以提供VM extension for WindowsVM extension for Linux的示例用法。

也许我遗漏了一些东西,但是根据您提供的信息,我相信您已经错过了上述第3步和第4步。因此,建议您先完成第3步和第4步,然后再进行第5步。 >

希望这会有所帮助!

答案 1 :(得分:-1)

我已经完成了任务。我使用了默认的 Scope 配置和默认的 Computer 查询。这两个组件是在从 azure 门户启用更新管理解决方案期间创建的。解决方案有效,如果有人想知道详细信息,请与我联系。