| @@ -8,8 +8,10 @@ | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="4.0.4" /> | |||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" /> | |||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" OutputItemType="Analyzer" /> | |||
| <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.0" /> | |||
| <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SendGrid" Version="3.0.2" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <None Update="host.json"> | |||
| @@ -0,0 +1,38 @@ | |||
| using System; | |||
| using Microsoft.Azure.Functions.Worker; | |||
| using Microsoft.Extensions.Logging; | |||
| namespace BlackRockReportFunction | |||
| { | |||
| public class ClockifyApiIntegrationFunction | |||
| { | |||
| private readonly ILogger _logger; | |||
| public ClockifyApiIntegrationFunction(ILoggerFactory loggerFactory) | |||
| { | |||
| _logger = loggerFactory.CreateLogger<ClockifyApiIntegrationFunction>(); | |||
| } | |||
| [Function("ClockifyApiIntegrationFunction")] | |||
| public void Run([TimerTrigger("*/5 * * * * *")] MyInfo myTimer) | |||
| { | |||
| _logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}"); | |||
| } | |||
| } | |||
| public class MyInfo | |||
| { | |||
| public MyScheduleStatus ScheduleStatus { get; set; } | |||
| public bool IsPastDue { get; set; } | |||
| } | |||
| public class MyScheduleStatus | |||
| { | |||
| public DateTime Last { get; set; } | |||
| public DateTime Next { get; set; } | |||
| public DateTime LastUpdated { get; set; } | |||
| } | |||
| } | |||
| @@ -1,6 +1,8 @@ | |||
| using System; | |||
| using Microsoft.Azure.Functions.Worker; | |||
| using Microsoft.Extensions.Logging; | |||
| using SendGrid.Helpers.Mail; | |||
| using Microsoft.Azure.WebJobs; | |||
| namespace BlackRockReportFunction | |||
| { | |||
| @@ -14,9 +16,22 @@ namespace BlackRockReportFunction | |||
| } | |||
| [Function("MailSenderFunction")] | |||
| public void Run([QueueTrigger("myqueue-items", Connection = "")] string myQueueItem) | |||
| [return: SendGrid(ApiKey = "SendGridApiKey")] | |||
| public SendGridMessage Run([QueueTrigger("queue1")] string myQueueItem) | |||
| { | |||
| _logger.LogInformation($"C# Queue trigger function processed: {myQueueItem}"); | |||
| var msg = new SendGridMessage() | |||
| { | |||
| From = new EmailAddress("nikola.jovanovic@dilig.net", "Nikola Jovanovic"), | |||
| Subject = "Test SendGrid Azure Function", | |||
| PlainTextContent = String.Format("If you read this text, then congratulations," + | |||
| " you did it! :) \n\n Also {0}", myQueueItem), | |||
| }; | |||
| msg.AddTo(new EmailAddress("nikolajovanovic3579@gmail.com", "Nikola Jovanovic")); | |||
| return msg; | |||
| } | |||
| } | |||
| } | |||