add wakey wakey

This commit is contained in:
Tommy Parnell
2018-10-05 20:48:33 -04:00
parent e31f88d9e8
commit 1ab46ce4ea
2 changed files with 29 additions and 1 deletions

24
WakeyWakey.cs Normal file
View File

@@ -0,0 +1,24 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace aka.terribledev.io
{
public static class WakeyWakey
{
static HttpClient client = new HttpClient();
[FunctionName("WakeyWakey")]
public async static Task Run([TimerTrigger("*/5 * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
var result = await client.GetAsync("https://aka.terribledev.io");
if(!result.IsSuccessStatusCode)
{
log.LogCritical("Error waking up redirect", result);
}
}
}
}

View File

@@ -34,12 +34,16 @@ namespace TerribleDev
public static class redirectFunctionTrig public static class redirectFunctionTrig
{ {
[FunctionName("redirectFunctionTrig")] [FunctionName("redirectFunctionTrig")]
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "{path}")] public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "{path}")]
HttpRequest req, HttpRequest req,
ILogger log, ILogger log,
string path) string path)
{ {
var name = path.ToString().TrimEnd('/'); var name = path.ToString().TrimEnd('/');
if(string.Equals(name, "livecheck"))
{
return new OkObjectResult("Hi! ^_^");
}
if (!RoutesDictionary.TryGetValue(name, out string result)) if (!RoutesDictionary.TryGetValue(name, out string result))
{ {
return new NotFoundObjectResult("hello"); return new NotFoundObjectResult("hello");