แก้ไข

แชร์ผ่าน


Create pre and post events (preview)

Applies to: ✔️ Windows VMs ✔️ Linux VMs ✔️ On-premises environment ✔️ Azure Arc-enabled servers ✔️ Azure VMs.

Pre and post events allows you to execute user-defined actions before and after the scheduled maintenance configuration. For more information, go through the workings of a pre and post event in Azure Update Manager.

This article describes on how to create pre and post events in Azure Update Manager.

Event Grid in schedule maintenance configurations

Azure Update Manager leverages Event grid to create and manage pre and post events. For more information, go through the overview of Event Grid. To trigger an event either before or after a schedule maintenance window, you require the following:

  1. Schedule maintenance configuration - You can create Pre and post events for a schedule maintenance configuration in Azure Update Manager. For more information, see schedule updates using maintenance configurations.
  2. Action to be performed in the pre or post event - You can use the Event handlers (Endpoints) supported by Event Grid to define actions or tasks. Here are examples on how to create Azure Automation Runbooks via Webhooks and Azure Functions. Within these Event handlers/Endpoints, you must define the actions that should be performed as part of pre and post events.
    1. Webhook - Create a PowerShell 7.2 Runbook and link the Runbook to a webhook.
    2. Azure Function - Create an Azure Function.
  3. Pre and post event - You can follow the steps shared in the following section to create a pre and post event for schedule maintenance configuration. To learn more about the terms used in the Basics tab of Event Grid, see Event Grid terms.

Create a pre and post event (preview)

Create pre and post events while creating a new schedule maintenance configuration

  1. Sign in to the Azure portal and go to Azure Update Manager.

  2. Under Manage, select Machines.

  3. Select Schedule updates from the ribbon at the top.

  4. In the Create a maintenance configuration page, select the Events tab.

  5. Select +Event Subscription to create pre/post event.

  6. On the Add Event Subscription page, enter the following details: In the Event Subscription Details section, provide an appropriate name.

    • Keep the schema as Event Grid Schema.
    • Enter the System Topic Name for the first event you create in this maintenance configuration. The same System Topic name will be auto populated for the consequent events.
    • In the Event Types section, Filter to Event Types, select the event types that you want to get pushed to the endpoint or destination. You can select either Pre Maintenance Event or Post Maintenance Event or both. To learn more about event types that are specific to schedule maintenance configurations, see Azure Event Types.
    • In the Endpoint details section, select the endpoint where you want to receive the response from.
  7. Select Add to create the pre and post events for the schedule upon its creation.

    Screenshot that shows how to add an event subscription.

Note

In the above flow, Webhook and Azure Functions are the two Event handlers/endpoints you can choose from. When you select Add, the event subscription is not created but added to the maintenance configuration. Event subscription is created along with the schedule maintenance configuration.

Create pre and post events on an existing schedule maintenance configuration

  1. Sign in to the Azure portal and go to Azure Update Manager.

  2. Under Manage, select Machines, Maintenance Configurations.

  3. In the Maintenance Configuration page, select the maintenance configuration to which you want to add a pre and post event.

  4. In the selected Maintenance configuration page, under Settings, select Events. Alternatively, under the Overview, select the card Create a maintenance event.

    Screenshot that shows the options to select to create a maintenance event.

  5. Select +Event Subscription to create Pre/Post Maintenance Event.

    Screenshot that shows the maintenance events.

  6. On the Create Event Subscription page, enter the following details:

    • In the Event Subscription Details section, provide an appropriate name.

    • Keep the schema as Event Grid Schema.

    • In the Topic Details section, provide an appropriate name to the System Topic Name.

    • In the Event Types section, Filter to Event Types, select the event types that you want to get pushed to the endpoint or destination. You can select between Pre Maintenance Event and Post Maintenance Event. To learn more about event types that are specific to schedule maintenance configurations, see Azure Event Types.

    • In the Endpoint details section, select the endpoint from where you want to receive the response from.

      Screenshot on how to create event subscription.

  7. Select Create to configure the pre and post events on an existing schedule.

Next steps

  • For an overview of pre and post events (preview) in Azure Update Manager, refer here.
  • To learn on how to manage pre and post events or to cancel a schedule run, see pre and post maintenance configuration events.
  • To learn how to use pre and post events to turn on and off your VMs using Webhooks, refer here.
  • To learn how to use pre and post events to turn on and off your VMs using Azure Functions, refer here.