【发布时间】:2017-11-24 01:19:51
【问题描述】:
我正在尝试在这篇文章之后以异步方法绑定到 blob 输出:How can I bind output values to my async Azure Function?
我有多个输出绑定,所以只返回不是一个选项
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);
}
}
我对 blob 的绑定是:
{
"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
}
但每当我这样做时,我都会得到以下信息:
错误:函数($WebHook)错误: Microsoft.Azure.WebJobs.Host:索引方法错误 'Functions.WebHook'。 Microsoft.Azure.WebJobs.Host:无法绑定 要键入的 Blob 'Microsoft.Azure.WebJobs.IAsyncCollector`1[System.String]'
【问题讨论】:
-
Blob 输出绑定不支持收集器,请参阅this issue。您需要输出 1 个还是多个项目?
-
只有一项。但是我需要在异步方法中进行,返回值需要是http响应。
标签: c# azure asynchronous azure-blob-storage azure-functions