-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathDaprStateOutputBindingUserDefinedType.cs
43 lines (37 loc) · 1.42 KB
/
DaprStateOutputBindingUserDefinedType.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
36
37
38
39
40
41
42
43
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
namespace dotnet_azurefunction
{
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Dapr;
using Microsoft.Extensions.Logging;
public static class DaprStateOutputBindingUserDefinedType
{
/// <summary>
/// Example to use Dapr Service Invocation Trigger and Dapr State Output binding to persist a new state into statestore
/// </summary>
[FunctionName("DaprStateOutputBindingUserDefinedType")]
public static Product Run(
[DaprServiceInvocationTrigger] Product payload,
[DaprState("%StateStoreName%", Key = "product")] out Product product,
ILogger log)
{
log.LogInformation("C# function processed a DaprStateOutputBindingUserDefinedType request from the Dapr Runtime.");
product = payload;
return payload;
}
}
public class Product
{
[JsonPropertyName("Name")]
public string Name { get; set; }
[JsonPropertyName("Description")]
public string Description { get; set; }
[JsonPropertyName("Quantity")]
public int Quantity { get; set; }
}
}