Azure Alert when a new resource is added/modified uppon a specific tag

264 Views Asked by At

We control our billings by a specific tag, for example: "Product_A", sometimes other teams are tagging resources incorrectly with our tag.

Is there a way to have an alert on Azure that send a notification when a new resource is added or modified in a resource group uppon our tag?

I'm open to others options.

Thanks in advance

1

There are 1 best solutions below

0
Jahnavi On

Azure Alert when a new resource is added/modified upon a specific tag: -

After a workaround on your requirement, I found few approaches, one of which is shown below to set up an alert rule conditionally.

In the Portal, create a log analytics workspace and browse to Logs on the left blade view. When you click on it, a query editor opens, which is used to retrieve the logs. I performed the query below as per the request you provided, and it was successful.

AzureActivity
| where ResourceGroup contains "xxxxx"
| where Properties contains "tags" and OperationName contains "Create" and OperationName contains "update"
| extend tags = tostring(parse_json(Properties).requestbody)
| where tags contains "CreatedDate" //Modify tag name as per your requirement

After that, go to New Alert rule to create an alert rule using the custom log search shown below.

enter image description here

Now, in the create rule, enter the required values and settings (for example, thresholdetc..) and create a rule accordingly.

enter image description here

Alert rule is created after all the above steps.

enter image description here

Another approach:

You can also ARM template creating an action group with an email target and enables all health notifications and it is clearly detailed in MSDoc with the sample template.