Optimizing Cloud Management: Leveraging Azure Update Manager with Pre and Post Events
Published May 20 2024 01:19 AM 1,791 Views
Microsoft

Introduction

As Azure Update Manager becomes the go-to solution for patching Azure VMs, it’s crucial to integrate efficient pre and post tasks to enhance reliability and control. This blog outlines a systematic approach to setting up these tasks, starting with initiating specific VMs based on their tags, and creating snapshots of the OS disk before updates. This preemptive measure ensures that if updates cause issues, restoring the system is straightforward and quick. Additional tasks will be integrated as needed to adapt to evolving requirements.

 

Requirements

To effectively implement the steps outlined, you should have:

  • A good understanding of Azure Automation Account.
  • An active Azure Automation Account.
  • A basic understanding of Runbooks and PowerShell.
  • Familiarity with Azure Update Manager and its functionalities.

Steps to Implement Pre and Post Events in Azure Update Manager

1. Set Up Maintenance Configuration Schedules: Start by configuring the maintenance schedules within Azure Update Manager to define when the updates should occur. Below a very basic example of how I set up mine. 

 

1.jpg2.jpg3.jpg4.jpg5.jpg6.jpg

 

6.1.jpg

 

2. Import Runbooks into Azure Automation Account: Import the necessary runbooks into your Azure Automation Account. These runbooks will automate the pre and post tasks.

You can find the runbooks in this Git Repo --> UpdateManagerStartSnapshotPatch 

 

7.jpg

 

3. Create Webhooks for Runbooks: Establish webhooks for each runbook. These webhooks provide a way to trigger runbooks externally, facilitating seamless automation during the update process. As you can see in below screenshots I use a tag called Patch with a value of Yes to let the script know which servers to patch. Feel free to make any changes as required. 

 

8.jpg

8.1.jpg

8.2.jpg

 

8.4.jpg

 

9.jpg

 

EXAMPLE OF MY VM TAGS

8.3.jpg

 

4. Establish an Event Grid System Topic: Set up an Event Grid System Topic, which will serve as the central hub for managing event notifications related to the update processes.

 

10.jpg

 

10.1.jpg

 

10.2.jpg

 

10.3.jpg

 

Subscribe to the Event Grid Topic: The subscription will automatically be created for you upon completion of the previous steps. We can also come back here to view how many times the event has fired. 

 

wernerrall_0-1713354293948.png

If everything was setup correctly you will be able to view how many times the event has occured. Please see below example from one of the other schedules. 

wernerrall_1-1713354444184.png

 

I hope this article could provide some guidance on how to use the pre and post actions for Azure Update Management. 

 

Disclaimer

The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts or Power BI Dashboards are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts or Power BI Dashboards be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. This blog post was written with the help of generative AI. 

 

Co-Authors
Version history
Last update:
‎Apr 17 2024 09:06 AM
Updated by: