0

Quick context :

I want to delete my VM(s) in a specific resource group if its CPU usage is below 30 for 1 hour.

Detailed explanation : Please refer alert-action group flow diagram (https://i.stack.imgur.com/I4gBD.png%60 ) or Below Image Flow

  • Resource Group -> Linux VM(s) , connected with Log analytics workspace

  • Created Azure Function - Delete-VM , which written in Powershell will Delete VM

  • Created Action Group (delete-Action) to trigger a mail notification and above Azure Function(Delete-VM)

  • Created alert rule with signal as Log & condition as custom Log query and configured above action group to take action.

Custom Query :

Perf | where TimeGenerated > ago(60m) | where (ObjectName == "Processor") | summarize AggregatedValue = avg(CounterValue) by Computer | where AggregatedValue < 100 | project Computer, AggregatedValue

Issue :

  • When condition breached and alert get fired.
  • Only Mail action is Triggered
  • Azure Function (Delete DVSM) is not executing.

How to Trigger Azure function when Alert fired.

kumar
  • 1

1 Answers1

0

I have followed the blog which created by cloudsma.

Workaround follows

I have created the Alert Group with Email notification alert and it will trigger the Azure Function. enter image description here

enter image description here

Adding Alert Rule:

enter image description here

Alert can be able to trigger in both Email and Azure Function

Alert Results

enter image description here enter image description here

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15