Azure WEB JOBS

Azure providers WebJobs that can fire various triggers including Cron-like schedulers. In order to run the Laravel scheduler you need to trigger the schedule:run command every minute. For now I’ll assume artisan lives in D:homesitewwwrootartisan which is the default location for PHP based deployments.

Create a new file called runsched.cmd or anything else als long as it has the .cmd extension. Edit the file with notepad and add:

php %HOME%sitewwwrootartisan schedule:run

Save the file and go to the Azure portal.

Select you WebApp and find WebJobs under the application settings. Click Add and a sidepanel will appear.

Give the WebJob a name, for example LaravelSchulder and upload the runsched.cmd file from the first step.

Set Type to Triggered and make sure Triggers is set to Scheduled.

Now you can specify how often the command must be triggered. Even the portal says ‘CRON Expression’ the cron format is not the same as the Linux notation. If you set the expression to all asterisks as shown in the Laravel documentation you’re command will be triggered every second, which is way too often for most applications. The correct CRON Expression is:

0 * * * * *

If you’re Job looks something like this click OK.

Azure WebJob Laravel Schuduler

The Laravel scheduler will now be triggered every minute. To verify that everything is working correctly you can trigger the job once yourself (Select the LaravelSchulder job and click Run) and check the job status. If Azure reports Failed under status check the logs and make sure you’ve entered the correct paths’
Hope that explains it.

Quick note: Microsoft likes to change Azure Portal on a regular basis, so any of these instructions may have changed by now.

Sources

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer
https://docs.microsoft.com/en-us/azure/app-service/webjobs-create