Hacking Azure Function Cold Start

Azure function requires subscription to remove cold start, for small project, it may not be cost effective hence creating a simple api call to "wake up" azure function during possible active time will be a good option temporarily

Action Plan

Create an api call php (NHM_cron.php), schedule to call to every 15 minutes during
Tue – Sun 10 to 6
Mon + PH off

Implementation

The api call:

https://node.azurewebsites.net/api/RetrieveAnchors?code=qq/27Mm4uk1g==

Cron job

using cpanel cron job

every 15 minutes, 10am – 18pm every weekday (Tue to Sat)

curl php setup

inside NHM_cron.php

<?php
        // create curl resource
        $ch = curl_init();

        // set url
        curl_setopt($ch, CURLOPT_URL, "https://node.azurewebsites.net/api/RetrieveAnchors?code=qq/27Mm4uk1g==");

        //return the transfer as a string
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        // $output contains the output string
        $output = curl_exec($ch);

        // close curl resource to free up system resources
        curl_close($ch);     
?>

Change server timezone

add the following to php.ini in root folder of the server

date.timezone = "Asia/Singapore";

https://www.php.net/manual/en/timezones.asia.php

Updated Solution:

https://console.cron-job.org/jobs