-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathInjectedFunction.cs
More file actions
26 lines (24 loc) · 889 Bytes
/
InjectedFunction.cs
File metadata and controls
26 lines (24 loc) · 889 Bytes
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
using Indigo.Functions.Injection;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using Sample.Storage;
namespace InjectionFunctionSample
{
public static class InjectedFunction
{
[FunctionName("InjectableFunctionExample")]
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "{key}")] HttpRequest req,
string key,
[Inject] IStorageAccess storageAccess,
ILogger logger)
{
logger.LogInformation($"Injected instance of {typeof(IStorageAccess)} is {storageAccess.GetType()}");
var value = storageAccess.RetrieveValue(key);
return new OkObjectResult($"Value for key '{key}' = '{value}'");
}
}
}