-
Notifications
You must be signed in to change notification settings - Fork 35
/
RetrieveSecret.java
31 lines (26 loc) · 1.19 KB
/
RetrieveSecret.java
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
package com.function;
import java.util.Map;
import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.annotation.FunctionName;
import com.microsoft.azure.functions.dapr.annotation.DaprSecretInput;
import com.microsoft.azure.functions.dapr.annotation.DaprServiceInvocationTrigger;
public class RetrieveSecret {
@FunctionName("RetrieveSecret")
public void run(
@DaprServiceInvocationTrigger(
methodName = "RetrieveSecret") Object args,
@DaprSecretInput(
secretStoreName = "kubernetes",
key = "my-secret",
metadata = "metadata.namespace=default")
Map<String, String> secret,
final ExecutionContext context) {
context.getLogger().info("Java 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
for (Map.Entry<String, String> entry : secret.entrySet()) {
context.getLogger().info(String.format("Stored secret: Key = %s, Value = %s", entry.getKey(), entry.getValue()));
}
}
}