-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMMSConfigUpsert.cs
More file actions
37 lines (35 loc) · 1.33 KB
/
Copy pathMMSConfigUpsert.cs
File metadata and controls
37 lines (35 loc) · 1.33 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
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.Cosmos;
namespace MMS.Function
{
public static class MMSConfigUpsert
{
[FunctionName("MMSConfigUpsert")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
var data = JsonConvert.DeserializeObject<Config>(requestBody);
Config newConfig = new Config()
{
id = data.id,
log_interval = data.log_interval,
data_post_api = data.data_post_api,
location = ""
};
Console.WriteLine($"input id: {newConfig.id}, input log: {newConfig.log_interval}, input data: {newConfig.data_post_api}");
CosmosConnect.PostConfig(newConfig);
return new OkObjectResult(newConfig);
}
}
}