-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathIsolatedFunctionsDemo.cs
More file actions
62 lines (50 loc) · 2.4 KB
/
IsolatedFunctionsDemo.cs
File metadata and controls
62 lines (50 loc) · 2.4 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.IO;
using System.Net;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
namespace IsolatedFunctionApps
{
//public static class IsolatedFunctionsDemo
//{
// [Function("SayHello")]
// public static async Task<HttpResponseData> Run(
// // When using HttpTrigger, use HttpRequestData wrapper for reading input Http Request
// [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
// FunctionContext executionContext)
// {
// // Use the FunctionContext.GetLogger to fetch instance of ILogger
// var logger = executionContext.GetLogger("Info");
// logger.LogInformation("Started execution of function");
// string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
// var data = JsonSerializer.Deserialize<UserDto>(requestBody);
// // Should use HttpResponseData as response
// var response = req.CreateResponse(HttpStatusCode.OK);
// response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
// response.WriteString($"Hello {data.Name}");
// return response;
// }
//}
//public class IsolatedFunctionsDemoInstance
//{
// [Function("SayHello1")]
// public async Task<HttpResponseData> Run(
// // When using HttpTrigger, use HttpRequestData wrapper for reading input Http Request
// [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
// FunctionContext executionContext)
// {
// // Use the FunctionContext.GetLogger to fetch instance of ILogger
// var logger = executionContext.GetLogger<IsolatedFunctionsDemoInstance>();
// logger.LogInformation("Started execution of function");
// string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
// var data = JsonSerializer.Deserialize<UserDto>(requestBody);
// // Should use HttpResponseData as response
// var response = req.CreateResponse(HttpStatusCode.OK);
// response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
// response.WriteString($"Hello {data.Name}");
// return response;
// }
//}
}