goo*_*gic 3 c# function azure .net-core
我需要从 Azure 函数进行一系列数据库调用,并在结果(文本块)可用时将结果返回给 http 调用方。这可能在一分钟左右的时间内偶尔发生。
我不需要“文件下载”响应,只需要通过响应流发送的数据。
有没有办法在 Azure 函数中写入响应正文流?
编辑:
尝试创建我自己的 IActionResult 在写入响应正文流时遇到问题Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
以下是 Azure 函数的示例HttpTrigger:
[FunctionName("Function1")]
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
return new OkResult();
}
Run Code Online (Sandbox Code Playgroud)
您可以使用以下参数获取响应对象HttpRequest req:
var response = req.HttpContext.Response;
Run Code Online (Sandbox Code Playgroud)
我们可以删除返回类型并简单地 return Task,然后按如下方式传输数据:
var response = req.HttpContext.Response;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6085 次 |
| 最近记录: |