【问题标题】:How to deploy Update Management to Azure resources the programmatic way如何以编程方式将更新管理部署到 Azure 资源
【发布时间】:2018-10-03 20:35:21
【问题描述】:

我目前正在尝试将 Azure 的更新管理解决方案设置到我已设置的资源组。我已经阅读了很多关于这个问题的文档,包括微软的: https://docs.microsoft.com/en-us/azure/automation/automation-update-management

使用 GUI 进行设置非常简单,但是我一直未能找到以编程方式部署它的方法。我想联系堆栈社区,看看是否有人能够部署一个使用带有代码库的更新管理的环境,或者是否有人找到/构建了一个 powershell 模块,该模块可用于在选定的 VM 上启用更新管理器

【问题讨论】:

    标签: azure powershell updates patch


    【解决方案1】:

    这块手臂模板应该可以工作:

    {
        "apiVersion": "2017-05-15-preview",
        "type": "Microsoft.Automation/automationAccounts/softwareUpdateConfigurations",
        "name": "automationName/softwareUpdateName",
        "location": "[resourceGroup().location]",
        "properties": {
            "updateConfiguration": {
                "operatingSystem": "Windows",
                "duration": "PT2H0M",
                "windows": {
                    "excludedKbNumbers": [
                        "168934",
                        "168973"
                    ],
                    "includedUpdateClassifications": "Critical",
                    "rebootSetting": "IfRequired"
                },
                "azureVirtualMachines": [
                    "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-01",
                    "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-02",
                    "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-03"
                ],
                "nonAzureComputerNames": [
                    "box1.contoso.com",
                    "box2.contoso.com"
                ]
            },
            "scheduleInfo": {
                "frequency": "Hour",
                "startTime": "2017-10-19T12:22:57+00:00",
                "timeZone": "America/Los_Angeles",
                "interval": 1,
                "expiryTime": "2018-11-09T11:22:57+00:00",
                "advancedSchedule": {
                    "weekDays": [
                        "Monday",
                        "Thursday"
                    ]
                }
            }
        }
    }
    

    您可以使用其余的 api 来了解如何以您需要的方式构造 properties

    您可以使用相同的 properties json 和 invoke-webrequest 作为有效负载,例如,或 curl。

    【讨论】:

    【解决方案2】:

    在 powershell 中与“Azure 更新”交互是通过“AzureRMAutomation”cmdlet 完成的。例如,计划软件更新使用“New-AzureRmAutomationSoftwareUpdateConfiguration”cmdlet。

    https://docs.microsoft.com/en-us/powershell/module/azurerm.automation/new-azurermautomationsoftwareupdateconfiguration?view=azurermps-6.13.0

    您应该能够在该目录中找到您想做的任何其他事情。

    我偶然发现了这个网站,它不如上述信息有用...

    https://sharepointyankee.com/2018/02/26/importing-powershell-modules-into-azure-automation/

    此过程允许您从模块库下载 powershell 模块。在简单搜索“更新”之后。我找到了 2 个模块“xWindowsUpdate”和“PSWindowsUpdate”。这些不直接与 azure 更新管理器交互,但在功能上实现了相同的结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-29
      • 2015-11-20
      • 2012-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多