How To use Azure Update management for Automating patch management of all Virtual machines under a subscription including future machines

Viewed 526
  1. I have an Azure policy which install Microsoft monitoring agent on all the VMs
  2. I have Automation Account which is linked to the Log analytics workspace.
  3. The Automation Account has a scheduler which has a dynamic query to fetch all the VMs with Tag "PatchManagement" Enabled = $true.
  4. The scheduler makes use of the Microsoft Runbook "Patch-MicrosoftOMSComputers" to apply the patched on the Dynamic VMs fetched by the above query.

The Issue is

  1. The update management is not Enabled on the Automation Account and the VM's
  2. Is there a way we can automate enabling of the Update management on all the VM's created in a subscription and link into the automation account update management using the query of the scheduler.

I followed the link "enter link description here", to implement this solution.

2 Answers

The link below enables the update management on the automation account.

I was missing the below section of code in my terraform

# Enable Update Management solution

resource "azurerm_log_analytics_solution" "update_solution" {
  depends_on = [
    azurerm_log_analytics_linked_service.autoacc_linked_log_workspace
  ]
  solution_name         = "Updates"
  location              = azurerm_resource_group.rg.location
  resource_group_name   = azurerm_resource_group.rg.name
  workspace_resource_id = azurerm_log_analytics_workspace.log_analytics_workspace.id
  workspace_name        = 
  azurerm_log_analytics_workspace.log_analytics_workspace.name

  plan {

    publisher = "Microsoft"

    product   = "OMSGallery/Updates"

  }

}

Reference link

Related