簡體   English   中英

如何將Azure Functions返回值綁定到輸出?

[英]How can I bind my Azure Functions return value to a output?

使用Azure函數時,是否可以將輸出綁定到函數的返回值?

是的,如果您將綁定名稱設置為$return那么您的函數返回的任何內容都將被發送到您的輸出綁定。 這將避免您必須為函數指定out <T> boundParam參數。

例:

捆綁

使用手動觸發器

{
  "bindings": [
    {
      "type": "blob",
      "name": "$return",
      "path": "testoutput/{rand-guid}.txt",
      "connection": "AzureWebJobsDashboard",
      "direction": "out"
    },
    {
      "type": "manualTrigger",
      "name": "input",
      "direction": "in"
    }
  ],
  "disabled": false
}

代碼(同步)

using System;

public static string Run(string input, TraceWriter log)
{
    log.Info($"C# manually triggered function called with input: {input}");
    await Task.Delay(1);

    return input;
}

代碼(異步)

using System;

public static async Task<string> Run(string input, TraceWriter log)
{
    log.Info($"C# manually triggered function called with input: {input}");
    await Task.Delay(1);

    return input;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM