-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTriggerPipeline.cs
55 lines (44 loc) · 1.71 KB
/
TriggerPipeline.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
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.Extensions.Logging;
using Azure.Identity;
using Azure.Core;
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
using groveale.Services;
using Google.Protobuf.WellKnownTypes;
namespace groveale
{
public class TriggerPipeline
{
private readonly ILogger _logger;
private readonly IAdxService _adxService;
private readonly ISynapseService _synapseService;
public TriggerPipeline(ILoggerFactory loggerFactory, IAdxService adxService, ISynapseService synapseService)
{
_logger = loggerFactory.CreateLogger<TriggerPipeline>();
_adxService = adxService;
_synapseService = synapseService;
}
[Function("TriggerPipeline")]
public async Task Run([TimerTrigger("0 0 3 * * 1")] 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}");
}
await _synapseService.TriggerPipelineAsync();
var additionalPipelineName = Environment.GetEnvironmentVariable("ADDITIONAL_PIPELINE_NAME");
if (!String.IsNullOrEmpty(additionalPipelineName))
{
await _synapseService.TriggerAdditionalPipelineAsync(additionalPipelineName);
}
var turnOnADX = Environment.GetEnvironmentVariable("TURN_ON_ADX");
if (turnOnADX == "true")
{
await _adxService.StartAdxClusterAsync();
}
}
}
}