-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimerTriggerFunction1.cs
More file actions
55 lines (49 loc) · 1.71 KB
/
TimerTriggerFunction1.cs
File metadata and controls
55 lines (49 loc) · 1.71 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Extensions.Sql;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
namespace MaxHRO.Function1
{
public class TimerTriggerFunction1
{
private readonly ILogger _logger;
public TimerTriggerFunction1(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<TimerTriggerFunction1>();
}
[Function("TimerTriggerFunction1")]
public OutputType Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer)
{
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
if (myTimer.ScheduleStatus is not null)
{
_logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus.Next}");
}
try
{
// Connect to Azure SQL Database via Binding
return new OutputType()
{
testItem = new TestItem
{
FrontName = "Werner",
LastName = "Brösel",
Birthday = new DateTime(1981, 12, 12),
CountShoes = new Random().Next(1,100)
}
};
}
catch (Exception ex)
{
_logger.LogError(ex, "Error");
return new OutputType();
}
}
}
public class OutputType
{
[SqlOutput("dbo.TestData", connectionStringSetting: "sqlconnect")]
public TestItem? testItem { get; set; }
}
}