· 6 years ago · Mar 12, 2019, 06:20 PM
1using Microsoft.Azure.WebJobs;
2using Microsoft.Extensions.Configuration;
3using Microsoft.Extensions.Logging;
4using System;
5using System.Threading.Tasks;
6
7namespace BotHealthChecker
8{
9 public static class HealthCheckFunc
10 {
11 private static readonly IConfiguration Configuration;
12
13 static HealthCheckFunc()
14 {
15 Configuration = new ConfigurationBuilder()
16 .AddJsonFile("local.settings.json", true, true)
17 .AddEnvironmentVariables()
18 .Build();
19 }
20
21 [FunctionName("BotHealthCheck")]
22 public static async Task Run([TimerTrigger("%TimerSchedule%", RunOnStartup = true)]TimerInfo myTimer, ILogger logger)
23 {
24 var secretKey = Configuration["ConnectorSecretKey"];
25 var botId = Configuration["BotId"];
26
27 Validate(secretKey,nameof(secretKey));
28 Validate(botId, nameof(botId));
29
30 var healthChecker = new HealthChecker(); //é©å½“ã«newã™ã‚‹ã®ã¯å¥½ãã˜ã‚ƒãªã„ã‘ã©..
31 await healthChecker.RunAsync(secretKey, botId, logger);
32 }
33
34 private static void Validate(string target, string propertyName)
35 {
36 if (target == null) throw new ArgumentNullException(propertyName);
37 }
38 }
39}