Search code examples
azureazure-alerts

Temporary disabling azure activity log alerts


I have some alerts set up based on activity log - when certain resources are create/updated. I would like to disabled them for the deployment time (Azure DevOps, including ARM template) - to not be spammed with unnecessary emails.

So before each deployment (and after deploying ARM template) I would run code like this:

az monitor activity-log alert list --resource-group ${RESOURCE_GROUP_NAME} --query "[].[name, enabled]" -o tsv | while read ALERT_NAME ALERT_STATUS
do
    if [[ ${ALERT_STATUS} == "True" ]]
    then
        az monitor activity-log alert update --resource-group ${RESOURCE_GROUP_NAME} --name ${ALERT_NAME} --enabled false
    fi
done

And switch them on as a last step of deployment.

However this doesn't seem to suppress the alerts. My guess is that it need some time to refresh status somewhere. Any clue what it might be and how to fix/workaround it?


Solution

  • You can use action rules to suppress alerts during deployments. See these docs on that: https://learn.microsoft.com/en-us/azure/azure-monitor/platform/alerts-action-rules