我正在運行Visual Studio 2017 Preview並在本地運行功能代碼,並且我使用開箱即用的Azure Function項目模板。我試圖讓定時器觸發的Azure函數使用輸出綁定向服務總線隊列發送消息,但它看起來像WebJob SDK無法將輸出綁定到字符串類型。Azure函數輸出服務總線綁定來自定時器觸發器
綁定
"bindings": [
{
"type": "serviceBus",
"name": "msg",
"queueName": "myqueue",
"connection": "ServiceBusQueue",
"accessRights": "manage",
"direction": "out"
}
]
定時器功能
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace MyFunctionApp
{
public static class TimerTrigger
{
[FunctionName("TimerTriggerCSharp")]
public static void Run([TimerTrigger("1 * * * * *", RunOnStartup = true)]TimerInfo myTimer, TraceWriter log, out string msg)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
msg = "Hello!";
}
}
}
錯誤消息
TimerTriggerCSharp:Microsoft.Azure.WebJobs.Host:錯誤索引 方法'Functions.TimerTriggerCSharp'。 Microsoft.Azure.WebJobs.Host: 無法綁定參數'msg'來鍵入字符串&。確保綁定支持參數 類型。如果您使用綁定擴展 (例如ServiceBus,Timers等),請確保您已在啓動代碼中爲擴展名調用 註冊方法(例如 config.UseServiceBus(),config.UseTimers( )等)。
我缺少的設置步驟,或做服務總線綁定真的不支持的out
參數