Trigger Azure Function based on incoming request to Azure Application Gateway

Viewed 117

I have a web app deployed across two Azure Virtual Machines along with Azure Application Gateway. Now I want to shutdown both the Azure VMs and look for any incoming request and based on that incoming request I want to trigger Azure Function app to restart the Azure Virtual Machines and keep it on for next 1 hour. This process will be automated.

How to trigger the azure function app on the incoming request?

Can anyone help me to get some reference material or good links related to it

1 Answers

You can use Powershell + Azure Functions to start/stop the vms:

Start-AzVM -ResourceGroupName $ResourceGroupName -Name $VMName -Verbose

and

Stop-AzVM -ResourceGroupName $ResourceGroupName -Name $VMName -Force -Verbose

But to intercep requests and invoke those functions, I don't think there's a way (yet), since App Gateway uses health probes to keep checking the status of the backend pools.

Related