0

I was asked to do a POC test that needs to toggle Azure Alert Rules to either enable or disable the alerts via the logic app.

So far I can get the logic app to display the json file of the "Microsoft. Insights/ActivityLogAlerts" that I have. Now I need help to figure out how I can enable/disable the alerts.

You can check the images for reference on my current setup.

enter image description here

enter image description here

PS. We can't use the alert processing rule since we don't want any alerts to appear on the alert dashboard because of monthly reporting purposes.

I tried doing the HTML request POST but I can't change the status of "enabled": false, to "enabled": true,

}
    "enabled": false,
    "description": "## THIS IS A TEST ALERT ##"
}
Skin
  • 9,085
  • 2
  • 13
  • 29

1 Answers1

0

When updating an Activity log alert, you need to make a PATCH or PUT request to https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}?api-version=2020-10-01 depending on what you want to update.

To simply disabled / enable the activity alert, use the PATCH request

PATCH https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRule?api-version=2020-10-01

{
  "properties": {
    "enabled": false
  }
}

https://learn.microsoft.com/en-us/rest/api/monitor/activity-log-alerts/update?tabs=HTTP

Alternatively use the PUT request to update the descriptions and properties.

PUT https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRule?api-version=2020-10-01

{
    "enabled": true,
    "description": "Description of sample Activity Log Alert rule."
  }
}

https://learn.microsoft.com/en-us/rest/api/monitor/activity-log-alerts/create-or-update?tabs=HTTP

I hope this helps

Alistair

TheAlistairRoss
  • 305
  • 1
  • 3