-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStartACIs.cs
29 lines (26 loc) · 1021 Bytes
/
StartACIs.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
using System.Threading.Tasks;
using Microsoft.Azure.Management.ContainerInstance.Fluent;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
namespace AzureScheduler
{
public static class StartACIs
{
[FunctionName("StartACIs")]
public static async Task Run([TimerTrigger("0 0 7 * * 1-5")]TimerInfo myTimer, ILogger log)
{
var azure = Configuration.GetAzureApi();
var acis = await azure.ContainerGroups.ListAsync();
await ResourceHelper.ProcessResources(
acis,
aci => aci.State != "Running",
aci => Start(aci, log),
log);
}
public static Task Start(IContainerGroup containerGroup, ILogger log)
{
log.LogInformation("Starting " + containerGroup.Name);
return ContainerGroupsOperationsExtensions.StartAsync(containerGroup.Manager.Inner.ContainerGroups, containerGroup.ResourceGroupName, containerGroup.Name);
}
}
}