Pre and Post events (preview) frequently asked questions

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

This article presents the frequently asked questions in the lifecycle of pre and post events (preview).

How to check the configuration of pre and post event on your schedule and its count?

  1. Sign in to the Azure portal and go to Azure Update Manager.
  2. Under Manage, select Machines, Maintenance Configurations.
  3. On the Maintenance Configuration page, select the configuration.
  4. Select Overview, and check Maintenance events.
    • If there are no pre and post events that are set up, select Configure to set up. Screenshot that shows how to configure new event.

    • If there are pre and post events associated to the configuration, you can see the count of pre and post events associated to the configuration in the Events page.

How to view the list of pre and post events set up on a maintenance configuration?

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

  2. Under Manage, select Machines, Maintenance Configurations.

  3. On the Maintenance Configuration page, select the configuration.

  4. On the selected maintenance configuration page, under Settings, select Events to view the pre and post events that you have created.

    The grid at the bottom of the Events subscription tab displays the names of both the pre and post events along with the corresponding Event Types.

    Screenshot that shows how to view the list of pre and post events.

How to view the list of different endpoints setup for pre and post events on a maintenance configuration?

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

  2. Under Manage, select Machines, Maintenance Configurations.

  3. On the Maintenance Configuration page, select the configuration.

  4. On the selected maintenance configuration page, under Settings, select Events to view the pre and post events that you have created.

    In the grid at the bottom of the Event Subscription tab, you can view the endpoint details.

    Screenshot that shows how to view endpoints.

How to check the successful delivery of a pre or post event to an endpoint from Event Grid?

  1. Sign in to the Azure portal and go to Azure Update Manager.
  2. Under Manage, select Machines, Maintenance Configurations.
  3. On the Maintenance Configuration page, select the configuration.
  4. On the selected maintenance configuration page, under Settings, select Events.
  5. In the Essentials section, view metrics to see the metrics for all the events that are part of the event subscription. In the grid, the count of the Published Events metric should match with the count of Matched Events metric. Both of these two values should also correspond with the Delivered Events count.
  6. To view the metrics specific to a pre or a post event, select the name of the event from the grid. Here, the count of Matched Events metric should match with the Delivered Events count.
  7. To view the time at which the event was triggered, hover over the line graph. Learn more.

How to check an unsuccessful delivery of a pre and post events to an endpoint from Event Grid?

  1. Sign in to the Azure portal and go to Azure Update Manager.
  2. Under Manage, select Machines, Maintenance Configurations.
  3. On the Maintenance Configuration page, select the configuration.
  4. On the selected maintenance configuration page, under Settings, select Events.
  5. In the Essentials section, view metrics to see the metrics for all the events that are part of the event subscription. Here, you find that the count of the metric Delivery Failed Events increase.
  6. You further setup, you can do either of the following:
    1. Create Azure Monitor Alerts on this failure count to get notified of it. Set alerts on Azure Event Grid metrics and activity logs. (OR)
    2. Enable Diagnostic logs by linking to Storage accounts or Log Analytics workspace. Enable diagnostic logs for Event Grid resources.

    Note

    You can anytime set up logs and alerts for a successful deliveries.

How to check if the endpoint has been triggered in the pre or post task?

  • The VM start operation requires the Automation Managed Identity to have Microsoft.Compute/virtualMachines/start/action permissions over the VMs to get started, and this permission is included in the VM Contributor role.
  • Ensure to import the PowerShell package - ThreadJob with the Module version:2.0.3.
  1. Sign in to the Azure portal and go to Azure Automation account.

  2. In your Automation account, under Process Automation, select Runbooks.

  3. Select the pre or post script linked to your Webhook in Event Grid.

  4. In Overview, you can view the status of the Runbook job. The trigger time should be approximately 30 minutes prior to the schedule start time. Once the job is finished, you can come back to the same section to confirm if the status is Completed.

    Screenshot that shows how to view the status of the Runbook job.

    Upon completion, you can confirm whether the prepatch installation process has been completed as planned. For instance, ensure that the VM has been either powered on or off.

For more information on how to retrieve details from Automation account's activity log:

How to check if the script in Webhooks using Runbooks is triggered from Event Grid?

  1. Sign in to the Azure portal and go to Azure Automation account.

  2. In your Automation account, under Process Automation, select Runbooks.

  3. Select the pre or post script linked to your Webhook in Event Grid.

  4. In Overview, you can view the status of the Runbook job. Select the Input tab to view the latest run of the job.

    Screenshot that shows how to view the latest run of the job.

How to check the cancelation of a schedule?

  1. Sign in to the Azure portal and go to Azure Update Manager.
  2. Under Manage, select Machines, Maintenance Configurations.
  3. On the Maintenance Configuration page, select the configuration.
  4. On the selected maintenance configuration page, under Settings, select Activity Log to view the pre and post events that you have created.
    1. If the current maintenance schedule was canceled, the operation name would be Write apply updates to a resource.

      Screenshot that shows how to view tif the current maintenance schedule has been canceled.

    2. Select the activity to view the details that the activity performs.

How to confirm if the cancelation is by user or system?

You can view the status of the maintenance job from the ARG query mentioned above to understand if you've canceled the job or the system. The error message confirms the status of the job.

The following query allows you to view the list of VMs for a given schedule or a maintenance configuration:

maintenanceresources  
| where type =~ "microsoft.maintenance/maintenanceconfigurations/applyupdates"  
| where properties.correlationId has "/subscriptions/<your-s-id> /resourcegroups/<your-rg-id> /providers/microsoft.maintenance/maintenanceconfigurations/<mc-name> /providers/microsoft.maintenance/applyupdates/"  
| order by name desc

Screenshot that shows the status of job that has been canceled by system or user.

How to check the status of the maintenance configuration?

  1. Sign in to the Azure portal and go to Azure Update Manager.
  2. Under Manage, select History.
  3. Select By Maintenance ID tab to view the jobs by maintenance configurations. For the respective maintenance run ID, you can view the status of the job.
  4. Select the Status to view the details of the job. Screenshot that shows detailed view of the job.

Why the scheduled run was cancelled by the system?

The system cancels the scheduled run if one or more of the following conditions are not met:

  1. If the maintenance configuration has at least one pre event subscribed and the schedule time is changed within the 40-minute window before the scheduled start time.
  2. If the pre-event was created within the 40-minute window before the scheduled start time.

Why the post event was not sent by the system?

If the user modifies the schedule run time after the pre-event has been triggered, the post event will not be sent because the scheduled time has been replaced with a new one.

Note

Azure Event Grid adheres to an at-least-once delivery paradigm. This implies that, in exceptional circumstances, there is a chance of the event handler being invoked more than once for a given event. Customers are advised to ensure that their event handler actions are idempotent. In other words, if the event handler is executed multiple times, it should not have any adverse effects. Implementing idempotency ensures the robustness of your application in the face of potential duplicate event invocations.

Next steps