我目前正在尝试将 Azure 的更新管理解决方案设置为我已设置的资源组。我已经阅读了很多关于这个问题的文档,包括Microsoft的文档: https://learn.microsoft.com/en-us/azure/automation/automation-update-management
使用 GUI 进行设置非常简单,但是我一直没有成功找到以编程方式部署它的方法。我想联系堆栈社区,看看是否有人能够部署使用代码库更新管理的环境,或者是否有人找到/构建了一个可用于在选定虚拟机上启用更新管理器的 powershell 模块
这个手臂模板应该可以工作:
{
"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"
]
}
}
}
}
您可以使用 REST API 了解如何按照您需要的方式构建properties
。
例如,您可以将相同的properties
JSON 与 invoke-webrequest 一起使用作为有效负载或 curl。
如何使用 Terraform 自动将更新管理部署到 Azure(分步(:
-
创建自动化帐户 -资源"azurerm_automation_account">
-
创建日志分析工作区 -资源"azurerm_log_analytics_workspace">
-
将以前创建的日志分析与自动化帐户链接 -资源"azurerm_log_analytics_linked_service
-
创建 Log Analytics 解决方案"更新" -资源"azurerm_log_analytics_solution">
plan { publisher = "Microsoft" product = "OMSGallery/Updates" }
-
使用 ARM 模板创建更新计划 地形资源 -资源"azurerm_resource_group_template_deployment">- 上面的4c74356b41注释中显示的示例代码
-
为要自动更新并添加到更新管理的 VM 添加Microsoft监视代理扩展,将它们与早期的日志分析工作区 -资源"azurerm_virtual_machine_extension"连接
与 powershell 中的"Azure Updates"交互是通过"AzureRMAutomation"cmdlet 完成的。例如,计划软件更新使用"New-AzureRmAutomationSoftwareUpdateConfiguration"cmdlet。
https://learn.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 更新管理器交互,但在功能上可实现相同的结果。