-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathSampleFunctionApp.cs
33 lines (29 loc) · 1.17 KB
/
SampleFunctionApp.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace FunctionApp1
{
public class SampleFunctionApp
{
private readonly ILogger _logger;
private readonly TelemetryClient _telemetryClient;
public SampleFunctionApp(ILoggerFactory loggerFactory, TelemetryClient telemetryClient)
{
_logger = loggerFactory.CreateLogger<SampleFunctionApp>();
_telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));
}
[Function("SampleFunctionApp")]
public void Run([TimerTrigger("*/30 * * * * *", RunOnStartup = true)] TimerInfo myTimer)
{
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
using (_telemetryClient.StartOperation<RequestTelemetry>("operation"))
{
if (myTimer.ScheduleStatus is not null)
{
_logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus.Next}");
}
}
}
}
}