-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathEchoServiceInvocation.cs
33 lines (29 loc) · 1.19 KB
/
EchoServiceInvocation.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
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
namespace dotnet_azurefunction
{
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Dapr;
using Microsoft.Extensions.Logging;
public static class EchoServiceInvocation
{
// The function is triggered the service invocation Dapr trigger,
// and is echoes back the same message via a HTTP output binding.
[FunctionName("EchoServiceInvocation")]
public static IActionResult Run(
[DaprServiceInvocationTrigger] string message,
ILogger log)
{
log.LogInformation("C# function received a EchoServiceInvocation request.");
log.LogInformation($"Echoing message: {message}");
// Return the same payload.
return !String.IsNullOrWhiteSpace(message) ?
(ActionResult)new OkObjectResult(message) :
new BadRequestObjectResult("Please pass a message in the request body.");
}
}
}