Howiecamp Howiecamp - 1 year ago 150
C# Question

How to set up HTTP outputs in Azure Functions

I've got a simple Azure function for which I set up a DocumentDB output (as an example):

Azure Functions DocumentDB output screenshot

I then added the

parameter to the function and assigned a value to it in the code (by the way I was surprised that when I set up the output that the runtime didn't automatically modify the function signature):

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}"

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:

Azure Functions HTTP output

and defined the
output parameter.

But now what? What's the process of assigning to res? I've of course got to define the destination, request type, parms, etc.

Answer Source


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 HttpClient and issuing the request). You can see an example in one of our templates here:

I hope this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download