-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStop.cs
More file actions
40 lines (33 loc) · 1.16 KB
/
Stop.cs
File metadata and controls
40 lines (33 loc) · 1.16 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
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Management.Fluent;
using X5ff.Aci.Control.Common;
namespace X5ff.Aci.Control
{
public static class Stop
{
private static IAzure GetAzureContext()
{
IAzure azure = Azure.Authenticate("credentials.json").WithDefaultSubscription();
var currentSubscription = azure.GetCurrentSubscription();
return azure;
}
[FunctionName("stop")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req,
ILogger log)
{
var aci = Environment.GetEnvironmentVariable("ACI_NAME");
var resourceGroup = Environment.GetEnvironmentVariable("ACI_RESOURCE_GROUP");
log.LogInformation($"Stopping ACI {aci}@{resourceGroup}");
var control = new ContainerInstanceControl();
await control.Stop(aci, resourceGroup);
return new OkResult();
}
}
}