-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathFunction1.cs
41 lines (33 loc) · 1.18 KB
/
Function1.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
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json;
using System.Net.Http;
using System.Threading.Tasks;
namespace StreamAnalytics
{
public static class Function1
{
[FunctionName("Function1")]
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]HttpRequestMessage message,
TraceWriter log,
[CosmosDB("MyCosmosAnalyticsDatabase", "NewFollowers", ConnectionStringSetting ="SomeEnvironmentVariable")]out NewFollower newFollower
)
{
log.Info("C# HTTP trigger function processed a request.");
var task = message.Content.ReadAsAsync<NewFollower>();
Task.WaitAll();
newFollower = task.Result;
//string requestBody = new StreamReader(req.Body).ReadToEnd();
//dynamic data = JsonConvert.DeserializeObject(requestBody);
//name = name ?? data?.name;
return newFollower != null
? (ActionResult)new OkObjectResult($"New Follower on {newFollower.StreamService}: {newFollower.Handle}")
: new BadRequestObjectResult("Bad format...");
}
}
}