-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatus.cs
More file actions
39 lines (36 loc) · 1.13 KB
/
Status.cs
File metadata and controls
39 lines (36 loc) · 1.13 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
using System;
using System.IO;
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 Newtonsoft.Json;
using Microsoft.Azure.Management.Fluent;
using X5ff.Aci.Control.Common;
namespace X5ff.Aci.Control
{
public static class Status
{
[FunctionName("status")]
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($"Retrieving status for ACI {aci}@{resourceGroup}");
var control = new ContainerInstanceControl();
var status = await control.GetStatus(aci, resourceGroup);
if (String.IsNullOrEmpty(status))
{
return new BadRequestResult();
}
else
{
return new OkObjectResult(status);
}
}
}
}