Skip to content

Instantly share code, notes, and snippets.

@bcnzer
Created December 18, 2017 19:55
Show Gist options
  • Select an option

  • Save bcnzer/c5359e1acc1e22acdc9918b2b24567b1 to your computer and use it in GitHub Desktop.

Select an option

Save bcnzer/c5359e1acc1e22acdc9918b2b24567b1 to your computer and use it in GitHub Desktop.
Example C# Azure Function timer function
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace WolfTrackerAPI
{
public static class PingTimer
{
[FunctionName("PingTimer")]
public static async Task Run([TimerTrigger("0 */4 * * * *")] TimerInfo myTimer, TraceWriter log)
{
// This CRON job executes every 4 minutes
log.Info($"PingTimer function executed at: {DateTime.Now}");
var client = new HttpClient();
await client.GetAsync(new Uri("https://wolftracker.nz/"));
log.Info($"PingTimer function executed completed at: {DateTime.Now}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment