-
Notifications
You must be signed in to change notification settings - Fork 4
/
DatabaseFunction.cs
35 lines (33 loc) · 1.17 KB
/
DatabaseFunction.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
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
using StackExchange.Redis;
using System.Threading.Tasks;
namespace Indigo.Functions.Redis.IntegrationTests.Target
{
public static class DatabaseFunction
{
[FunctionName("DatabaseFunction")]
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "database/{key}")] HttpRequest request,
string key,
[Redis] IDatabase database,
TraceWriter log)
{
string value = database.StringGet(key);
return new OkObjectResult(value);
}
[FunctionName("DatabaseAsyncFunction")]
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "databaseasync/{key}")] HttpRequest request,
string key,
[Redis] IDatabase database,
TraceWriter log)
{
string value = await database.StringGetAsync(key);
return new OkObjectResult(value);
}
}
}