author | ms.service | ms.topic | ms.date | ms.author |
---|---|---|---|---|
ggailey777 |
azure-functions |
include |
03/06/2024 |
glenga |
The following example shows the function definition after adding a Queue Storage output binding to an HTTP triggered function:
::: zone pivot="programming-language-csharp"
Because an HTTP triggered function also returns an HTTP response, the function returns a MultiResponse
object, which represents both the HTTP and queue output.
[Function("HttpExample")]
public static MultiResponse Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequest req,
FunctionContext executionContext)
{
This example is the definition of the MultiResponse
object that includes the output binding:
public class MultiResponse
{
[QueueOutput("outqueue",Connection = "AzureWebJobsStorage")]
public string[] Messages { get; set; }
public IActionResult HttpResponse { get; set; }
}
When applying that example to your own project, you might need to change HttpRequest
to HttpRequestData
and IActionResult
to HttpResponseData
, depending on if you are using ASP.NET Core integration or not.
:::code language="csharp" source="~/functions-docs-csharp/functions-add-output-binding-storage-queue-cli/HttpExample.cs" range="14-18" highlight="4":::
Messages are sent to the queue when the function completes. The way you define the output binding depends on your process model. For more information, including links to example binding code that you can refer to, see Add bindings to a function.
::: zone-end
::: zone pivot="programming-language-java"
:::code language="java" source="~/functions-quickstart-java/functions-add-output-binding-storage-queue/src/main/java/com/function/Function.java" range="16-22" highlight="5-6":::
For more information, including links to example binding code that you can refer to, see Add bindings to a function.
::: zone-end
::: zone pivot="programming-language-javascript"
Example binding for Node.js model v4 not yet available.
:::code language="json" source="~/functions-docs-javascript/functions-add-output-binding-storage-queue-cli/HttpExample/function.json" highlight="18-24" :::
The way you define the output binding depends on the version of your Node.js model. For more information, including links to example binding code that you can refer to, see Add bindings to a function.
::: zone-end
::: zone pivot="programming-language-powershell"
:::code language="powershell" range="18-19" source="~/functions-docs-powershell/functions-add-output-binding-storage-queue-cli/HttpExample/run.ps1" highlight="18-24":::
For more information, including links to example binding code that you can refer to, see Add bindings to a function.
::: zone-end
::: zone pivot="programming-language-python"
:::code language="python" source="~/functions-docs-python-v2/function_app.py" range="6-9" highlight="2":::
:::code language="json" source="~/functions-docs-javascript/functions-add-output-binding-storage-queue-cli/HttpExample/function.json" highlight="18-24":::
The way you define the output binding depends on the version of your Python model. For more information, including links to example binding code that you can refer to, see Add bindings to a function.
::: zone-end
::: zone pivot="programming-language-typescript"
Example binding for Node.js model v4 not yet available.
:::code language="json" source="~/functions-docs-javascript/functions-add-output-binding-storage-queue-cli/HttpExample/function.json" highlight="18-24":::
The way you define the output binding depends on the version of your Node.js model. For more information, including links to example binding code that you can refer to, see Add bindings to a function. ::: zone-end