如何在Azure Functions中设置HTTP输出 [英] How to set up HTTP outputs in Azure Functions
问题描述
我有一个简单的Azure函数,为此我设置了DocumentDB输出:
然后,
我在函数中添加了outputDocument
参数,并在代码中为其分配了一个值(通过这种方式,我感到惊讶的是,当我设置输出时,运行时不会自动修改函数签名):
using System;
public static void Run(string input, out object outputDocument, TraceWriter log)
{
log.Info($"C# manually triggered function called with input: {input}");
outputDocument = new {
text = $"I'm running in a C# function! {input}"
};
}
当我运行该函数时,Azure Functions运行时会执行绑定魔术,并创建DocumentDB文档.
然后我设置一个HTTP输出:
并定义了res
输出参数.
但是现在呢?分配给res的过程是什么?我当然必须定义目标,请求类型,参数等.
Howiecamp,
HTTP输出绑定与HTTP触发器一起用作HTTP请求的响应处理程序.
当前,没有可以通过HTTP为您发送输出有效负载的输出绑定,因此您需要根据功能代码发出该HTTP请求(例如,使用 When I run the function the Azure Functions runtime does it's binding magic and the DocumentDB document gets created. I then set up an HTTP output: and defined the But now what? What's the process of assigning to res? I've of course got to define the destination, request type, parms, etc. Howiecamp, The HTTP output binding works in conjunction with the HTTP Trigger to act as the response handler for an HTTP request. Currently, there isn't an output binding that would send the output payload over HTTP for you, so you'd need to make that HTTP request from your function code (e.g. using the I hope this helps! 这篇关于如何在Azure Functions中设置HTTP输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!HttpClient
并发出请求).您可以在此处的模板之一中查看示例:res
output parameter.HttpClient
and issuing the request). You can see an example in one of our templates here: https://github.com/Azure/azure-webjobs-sdk-templates/blob/10650dbf9c4bad75b0c89b9c355edc53fe913cde/Templates/GitHubCommenter-CSharp/run.csx#L40-L49