Created
December 18, 2017 19:55
-
-
Save bcnzer/c5359e1acc1e22acdc9918b2b24567b1 to your computer and use it in GitHub Desktop.
Example C# Azure Function timer function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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