小编Aar*_*one的帖子

Azure函数输出服务总线绑定从计时器触发器

我正在运行Visual Studio 2017 Preview并在本地运行功能代码,我正在使用开箱即用的Azure Function项目模板.我正在尝试使用定时器触发的Azure功能使用输出绑定将消息发送到服务总线队列,但看起来WebJob SDK无法将输出绑定到字符串类型.

捆绑

 "bindings": [
    {
      "type": "serviceBus",
      "name": "msg",
      "queueName": "myqueue",
      "connection": "ServiceBusQueue",
      "accessRights": "manage",
      "direction": "out"
    }
  ]
Run Code Online (Sandbox Code Playgroud)

定时器功能

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!";
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

错误信息

TimerTriggerCSharp:Microsoft.Azure.WebJobs.Host:错误索引方法'Functions.TimerTriggerCSharp'.Microsoft.Azure.WebJobs.Host:无法将参数'msg'绑定到String&.确保绑定支持参数Type.如果您正在使用绑定扩展(例如ServiceBus,Timers等),请确保您已在启动代码中调用扩展的注册方法(例如config.UseServiceBus(),config.UseTimers()等).

我错过了设置中的一个步骤,或者Service Bus绑定是否真的不支持out参数的字符串

c# azure azureservicebus azure-webjobs azure-functions

3
推荐指数
1
解决办法
2531
查看次数