【发布时间】:2023-03-18 16:10:01
【问题描述】:
我有一个由 http 请求触发并使用绑定输出到 Azure 存储队列并返回 http 响应的 Azure 函数。
当使用 Functions.Worker 程序集为 dotnet-isolated 编码时,此方法有效。首先,我为队列消息和 http 响应声明了一个类型:
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
namespace SmsRouter.AzFunc
{
public class QueueAndHttpOutputType
{
[QueueOutput("%SendSmsQueueName%")]
public string QueueMessage { get; set; } = "";
public HttpResponseData HttpResponse { get; set; }
}
}
然后我将其用作 Azure 函数的返回类型:
[Function(nameof(SendSimpleSms))]
public async Task<QueueAndHttpOutputType> SendSimpleSms([HttpTrigger(AuthorizationLevel.Function, "post", Route = "v1.0/simple-sms")] HttpRequestData req,
FunctionContext executionContext)
不幸的是,由于this issue,我需要降级我的解决方案以使用 dotnet 3.1 和 Azure Functions 的进程内模型。
有谁知道我如何使用旧式进程内 Azure 函数实现相同的行为?
【问题讨论】:
-
我正在尝试使用具有 Queue 作为输出绑定的 Http 触发器与 .Net 5 一起使用类似的东西。我看到的大多数示例都是针对 3.1 或更低版本的。如果您可以检查我的问题stackoverflow.com/questions/69910895/…,将不胜感激
-
看起来你已经有了答案:)
-
很难在 MultiResponse 中找到命名空间或块 4 输出绑定 [QueueOutput("xx-data")]。使用 System.Net;使用 Microsoft.Azure.Functions.Worker.Extensions;使用 Microsoft.Azure.Functions.Worker.Http;使用 Azure.Storage.Queues;使用 Azure.Storage.Queues.Models; namespace XXX.Models { public class MultiResponse { [QueueOutput("xxx-data")] stackoverflow.com/questions/69910895
标签: azure-functions