Last active
March 19, 2021 06:56
-
-
Save gsscoder/ff78ee1ec22eeaa3afcb43274af04956 to your computer and use it in GitHub Desktop.
Simple C# availability canary Function App
This file contains 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.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Azure.WebJobs.Extensions.Http; | |
using Microsoft.Extensions.Logging; | |
namespace HealthTest2 | |
{ | |
public class CanaryFunction | |
{ | |
readonly ILogger _logger; | |
public CanaryFunction(ILoggerFactory loggerFactory) | |
{ | |
_logger = loggerFactory.CreateLogger("Function.CanaryFunction.User"); | |
} | |
[FunctionName("FunctionOK")] | |
public Task<IActionResult> RunOk( | |
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "ok")] HttpRequest req) | |
{ | |
_logger.LogInformation("Helth test request: OK"); | |
return Task.FromResult<IActionResult>(new OkObjectResult("OK")); | |
} | |
[FunctionName("FunctionBAD")] | |
public Task<IActionResult> RunBad( | |
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "bad")] HttpRequest req) | |
{ | |
_logger.LogInformation("Helth test request: BAD"); | |
return Task.FromResult<IActionResult>(new BadRequestObjectResult("BAD")); | |
} | |
[FunctionName("FunctionERR")] | |
public Task<IActionResult> RunErr( | |
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "err")] HttpRequest req) | |
{ | |
_logger.LogInformation("Helth test request: ERR"); | |
throw new Exception("ERR"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment