更新时间:2022-06-19 03:04:51
Blob 输出绑定不支持收集器,请参阅此 问题.
Collectors are not supported for Blob output bindings, see this issue.
对于可变数量的输出 blob(在您的情况下为 0 或 1,但可以是任意数量),您必须使用命令式绑定.从您的 function.json
中删除 collection
绑定,然后执行以下操作:
For variable amount of output blobs (0 or 1 in your case, but can be any), you would have to use imperative bindings. Remove collection
binding from your function.json
and then do this:
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, Binder binder)
{
if (req.Method == HttpMethod.Post)
{
string jsonContent = await req.Content.ReadAsStringAsync();
var attributes = new Attribute[]
{
new BlobAttribute("testdata/{rand-guid}.txt"),
new StorageAccountAttribute("test_STORAGE")
};
using (var writer = await binder.BindAsync<TextWriter>(attributes))
{
writer.Write(jsonContent);
}
return req.CreateResponse(HttpStatusCode.OK);
}
else
{
return req.CreateResponse(HttpStatusCode.BadRequest);
}
}