I'm trying to bind to a blob output in an Async method following this post: How can I bind output values to my async Azure Function?
I have multiple output bindings so just returning is not an option
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, IAsyncCollector<string> collection, TraceWriter log)
{
if (req.Method == HttpMethod.Post)
{
string jsonContent = await req.Content.ReadAsStringAsync();
// Save to blob
await collection.AddAsync(jsonContent);
return req.CreateResponse(HttpStatusCode.OK);
}
else
{
return req.CreateResponse(HttpStatusCode.BadRequest);
}
}
My binding for the blob is :
{
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in"
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"type": "blob",
"name": "collection",
"path": "testdata/{rand-guid}.txt",
"connection": "test_STORAGE",
"direction": "out"
}
],
"disabled": false
}
But whenever I do this I get the following:
Error: Function ($WebHook) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.WebHook'. Microsoft.Azure.WebJobs.Host: Can't bind Blob to type 'Microsoft.Azure.WebJobs.IAsyncCollector`1[System.String]'