-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetVisit.cs
33 lines (32 loc) · 1.34 KB
/
GetVisit.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
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 System.Text;
using System.Net.Http;
namespace Company.Function
{
public static class GetVisit
{
[FunctionName("GetVisit")]
public static HttpResponseMessage Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
[CosmosDB(databaseName:"AzureResume",collectionName:"counter",ConnectionStringSetting ="AzureConnectionStrings",Id ="1",PartitionKey ="1")] counter counter,
[CosmosDB(databaseName:"AzureResume",collectionName:"counter",ConnectionStringSetting ="AzureConnectionStrings",Id ="1",PartitionKey ="1")] out counter updatedcounter,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
updatedcounter = counter;
updatedcounter.count += 1;
var jsontoreturn = JsonConvert.SerializeObject(counter);
return new HttpResponseMessage(System.Net.HttpStatusCode.OK){
Content = new StringContent(jsontoreturn, Encoding.UTF8 , "application/json")
};
}
}
}