-
Notifications
You must be signed in to change notification settings - Fork 35
/
RetrieveSecret.cs
37 lines (33 loc) · 1.46 KB
/
RetrieveSecret.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
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
namespace dotnet_isolated_azurefunction
{
using System.Collections.Generic;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Extensions.Dapr;
using Microsoft.Extensions.Logging;
public static class RetrieveSecret
{
/// <summary>
/// Example to use Dapr Service Invocation Trigger and Dapr Secret input binding to retrieve a saved state from statestore
/// </summary>
[Function("RetrieveSecret")]
public static void Run(
[DaprServiceInvocationTrigger] object args,
[DaprSecretInput("kubernetes", "my-secret", Metadata = "metadata.namespace=default")] IDictionary<string, string> secret,
FunctionContext functionContext)
{
var log = functionContext.GetLogger("RetrieveSecret");
log.LogInformation("C# function processed a RetrieveSecret request from the Dapr Runtime.");
// print the fetched secret value
// this is only for demo purpose
// please do not log any real secret in your production code
foreach (var kvp in secret)
{
log.LogInformation("Stored secret: Key = {0}, Value = {1}", kvp.Key, kvp.Value);
}
}
}
}