使用Azure Functions时,是否可以将输出绑定到我的函数的返回值?
答案 0 :(得分:2)
是的,如果您将绑定名称设置为$return
,那么您的函数返回的任何内容都将被发送到您的输出绑定。这样可以避免为函数指定out <T> boundParam
参数。
使用手动触发器
{
"bindings": [
{
"type": "blob",
"name": "$return",
"path": "testoutput/{rand-guid}.txt",
"connection": "AzureWebJobsDashboard",
"direction": "out"
},
{
"type": "manualTrigger",
"name": "input",
"direction": "in"
}
],
"disabled": false
}
using System;
public static string Run(string input, TraceWriter log)
{
log.Info($"C# manually triggered function called with input: {input}");
await Task.Delay(1);
return input;
}
using System;
public static async Task<string> Run(string input, TraceWriter log)
{
log.Info($"C# manually triggered function called with input: {input}");
await Task.Delay(1);
return input;
}