Out bindings has example:
ICollector<T> (to output multiple blobs)
And also:
Path must contain the container name and the blob name to write to. For example,
if you have a queue trigger in your function, you can use "path":
"samples-workitems/{queueTrigger}" to point to a blob in the samples-workitems
container with a name that matches the blob name specified in the trigger
message.
And default in "Integrate" UI has default as:
Path: outcontainer/{rand-guid}
But this isn't sufficient for me to make headway. If I'm coding in C#, what is the syntax for function.json and for run.csx to output multiple blobs to a container?
There are several different ways you can accomplish this. First, if the number of blobs you need to output is fixed, you can just use multiple output bindings.
using System;
public class Input
{
public string Container { get; set; }
public string First { get; set; }
public string Second { get; set; }
}
public static void Run(Input input, out string first, out string second, TraceWriter log)
{
log.Info($"Writing 2 blobs to container {input.Container}");
first = "Azure";
second = "Functions";
}
And the corresponding function.json:
{
"bindings": [
{
"type": "manualTrigger",
"direction": "in",
"name": "input"
},
{
"type": "blob",
"name": "first",
"path": "{Container}/{First}",
"connection": "functionfun_STORAGE",
"direction": "out"
},
{
"type": "blob",
"name": "second",
"path": "{Container}/{Second}",
"connection": "functionfun_STORAGE",
"direction": "out"
}
]
}
To test the above, I send a test JSON payload to the function, and the blobs are generated:
{
Container: "test",
First: "test1",
Second: "test2"
}
The sample above demonstrates how the blob container/name values can be bound from the input (via the {Container}/{First}
{Container}/{Second}
path expressions). You just have to define a POCO capturing the values you want to bind to. I used ManualTrigger here for simplicity, but this works for the other trigger types as well. Also, while I chose to bind to out string
Types, you can bind to any of the other supported types: TextWriter
, Stream
, CloudBlockBlob
, etc.
If the number of blobs you need to output is variable, then you can use Binder to imperatively bind and write blobs in your function code. See here for more details. To bind to multiple outputs, you'd just perform multiple imperative bindings using that technique.
FYI: our documentation was incorrect, so I logged a bug here to get that fixed :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With