Search code examples
azureazure-functionsazure-virtual-machine

How to trigger an executable installed on azure vm through a function app


I am looking for a way to trigger or run an executable daily at a specific time on azure virtual machine through function app. Is there a way azure function app can talk to virtual machine?

Going through samples on microsoft learn site I didnt find any way to do this. I can try adding it to task scheduler but it will be difficult to manage in production and view logs or start/stop service as team has limited access in production.


Solution

  • You can use azure PowerShell timer trigger function to run executables at a given time.

    • Here you need to create a function app using PowerShell core:

    enter image description here

    Then create the azure function. Open Function App and then click on Functions and click on Create:

    enter image description here

    Then click on Timer Trigger and then set the time interval you want as below:

    enter image description here

    Then open the created function:

    enter image description here

    PowerShell Script to run on VM. As an Alternative you can use Automations and Logic apps as @Skin Commented.