When using Azure Functions is it possible to bind my outputs to the return value of my function?
1 Answer
Yes, if you set your binding name to $return then whatever your function returns will be sent to your output binding. This will avoid you having to specify an out <T> boundParam parameter to your function.
Example:
Binding
Using a manual trigger
{
"bindings": [
{
"type": "blob",
"name": "$return",
"path": "testoutput/{rand-guid}.txt",
"connection": "AzureWebJobsDashboard",
"direction": "out"
},
{
"type": "manualTrigger",
"name": "input",
"direction": "in"
}
],
"disabled": false
}
Code (synchronous)
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;
}
Code (async)
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;
}