Laravel scheduler triggered by Azure Scheduled Functions.
digitalclaim/azure-scheduler-laravel is a Laravel package for laravel scheduler triggered by azure scheduled functions..
It currently has 0 GitHub stars and 119 downloads on Packagist (latest version v1.0.0-alpha1).
Install it with composer require digitalclaim/azure-scheduler-laravel.
Discover more Laravel packages by digitalclaim
or browse all Laravel packages to compare alternatives.
Last updated
Laravel scheduler triggered by Azure Scheduled Functions. Instead of a CronJob the scheduled cloud function will request a callback url which triggers the Laravel scheduler.
This package is inspired by stackkit/laravel-google-cloud-scheduler
Warning: The callback route is rate limited to only one request per limit. Laravel sub-minute tasks are not supported.
You can install the package via composer:
composer require digitalclaim/azure-scheduler-laravel
You can publish the config file with:
php artisan vendor:publish --tag="azure-scheduler-laravel-config"
This is the contents of the published config file:
return [
];
php artisan down) you must modify the PreventRequestsDuringMaintenance middleware:<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
'/handle-scheduler',
];
}
public/index.php:/*
|--------------------------------------------------------------------------
| Check If Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is maintenance / demo mode via the "down" command we
| will require this file so that any prerendered template can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
require __DIR__.'/../storage/framework/maintenance.php';
}
+
/*
|--------------------------------------------------------------------------
| Manually Set Running In Console for Google Cloud Scheduler
|--------------------------------------------------------------------------
|
| Some service providers only register their commands if the application
| is running from the console. Since we are calling Cloud Scheduler
| from the browser we must manually trick the application into
| thinking that it is being run from the command line.
|
*/
+
if (($_SERVER['REQUEST_URI'] ?? '') === '/cloud-scheduler-job') {
$_ENV['APP_RUNNING_IN_CONSOLE'] = true;
}
+
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/
require __DIR__.'/../vendor/autoload.php';
Copy the code here:
/*
|--------------------------------------------------------------------------
| Manually Set Running In Console for Azure Scheduler
|--------------------------------------------------------------------------
|
| Some service providers only register their commands if the application
| is running from the console. Since we are calling Azure Scheduler
| from the browser we must manually trick the application into
| thinking that it is being run from the command line.
|
*/
if (($_SERVER['REQUEST_URI'] ?? '') === '/handle-scheduler') {
$_ENV['APP_RUNNING_IN_CONSOLE'] = true;
}
0 * * * * *:const axios = require("axios");
module.exports = async function (context, myTimer) {
try {
const response = await axios.get(
"https://YOURSITE.azurewebsites.net/handle-scheduler"
);
context.log(response.data);
} catch (error) {
// If the promise rejects, an error will be thrown and caught here
context.log(error);
}
context.done();
};
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.