Optimizing Cloud Management: Leveraging Azure Update Manager with Pre and Post Events
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.
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
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.
EXAMPLE OF MY VM TAGS
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.
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.
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.
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.
Microsoft Tech Community – Latest Blogs –Read More