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 :)