Friday, October 21, 2016

Cron Scheduling and Nano Services in Open Source Azure Functions

There are many ways to schedule jobs in Azure.  An interesting and fairly simple one available is to use Azure Functions, a lil' brudder of WebJobs.  For up to 1 million 1 second functions, there is no cost.  You can schedule a job function in Bash, C#, F#, NodeJs, Python, Java, etc.
https://azure.microsoft.com/en-us/documentation/articles/functions-bindings-timer/

Example json for a function.  http://www.crontab-generator.org/ for those who have not mastered the art of reading job schedules in Cron, this will run at 3:25am UTC every Monday - Friday.

In this case, your "crontab" or cron table part of the JSON formatted job definition.

{
  "bindings": [
    {
      "schedule": "25 3 * * 1-5",
      "name": "nightlyReports",
      "type": "timerTrigger",
      "direction": "in"
    }
  ],
  "disabled": false
}

This is the function example to log the timer event.

public static void Run(TimerInfo myTimer, TraceWriter log)
{
    log.Info($"C# Timer trigger function executed at: {DateTime.Now}");    
}

If your job is to execute a SQL stored procedure such as an SSIS proc to kick off an ETL package, or archive / groom data.
https://azure.microsoft.com/en-us/documentation/articles/functions-scenario-database-table-cleanup/

Another example is an event-based trigger coming from an Event Hub, or Blob Storage based trigger coming from a blob, table, queue, or file drop.

Once a function has been created, you can test or run the function with cURL by copying the Function Url.
https://azure.microsoft.com/en-us/documentation/articles/functions-test-a-function/

The code is in GitHub, packaged as the Azure Webjobs SDK Script.
https://github.com/azure/azure-webjobs-sdk-script

Announced at Build 2016, Some facts on Azure Functions from MSFT Playground
https://msftplayground.com/2016/05/facts-azure-functions/

Do you use Azure Web Jobs or the new Functions Preview?
https://blog.kloud.com.au/2016/09/14/azure-functions-or-webjobs/

Functions Reference
https://azure.microsoft.com/en-us/documentation/articles/functions-reference/

Functions with Logic Apps
https://azure.microsoft.com/en-us/documentation/articles/app-service-logic-azure-functions/

Continuous Deployment
https://azure.microsoft.com/en-us/documentation/articles/functions-continuous-deployment/


1 comment:

netflix customer service said...
This comment has been removed by a blog administrator.