azureazure-functionsazure-vm-scale-setazure-webhooks

How to trigger an azure function based on scale in or scale out events in vmss


I have a situation in which I need to trigger an azure function based on scale in or scale out events on some particular virtual machine scale set. My first idea was to use event grid triggers to trigger azure function based on resource modification on the vmss. However, it also triggers the function when any other editing event occurs besides scale in or scale out.

I also tried to specify the triggering method of the function to be http requests and specified the function URL in webhook section, as shown in the picture. However the function is not triggered.

enter image description here

How can I accomplish my intend?


Solution

  • I have use same method as yours to trigger the Http Trigger http_trigger when scale in and scale out events occurs in my environment using webhook, this worked for me.

    I have deployed Http trigger in Azure function app and copied the URL of the Http Trigger http_trigger.

    Note:- Make sure you are using correct URL

    enter image description here

    I have set rule for scale in and scale out. I have reduced the threshold percentage to trigger scale in and scale out more frequently.

    enter image description here

    I set the URL of the function trigger in webhook. and mail id to get the notification too.

    enter image description here

    Output:

    scale in:

    enter image description here

    enter image description here

    enter image description here

    scale out:

    enter image description here

    enter image description here

    enter image description here