Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 来自计时器触发器的Azure函数输出服务总线绑定_C#_Azure_Azure Functions_Azureservicebus_Azure Webjobs - Fatal编程技术网

C# 来自计时器触发器的Azure函数输出服务总线绑定

C# 来自计时器触发器的Azure函数输出服务总线绑定,c#,azure,azure-functions,azureservicebus,azure-webjobs,C#,Azure,Azure Functions,Azureservicebus,Azure Webjobs,我正在运行Visual Studio 2017预览并在本地运行函数代码,我正在使用现成的Azure函数项目模板。我试图让一个由计时器触发的Azure函数使用输出绑定向服务总线队列发送消息,但看起来WebJob SDK无法将输出绑定到字符串类型 绑定 "bindings": [ { "type": "serviceBus", "name": "msg", "queueName": "myqueue", "connection": "Serv

我正在运行Visual Studio 2017预览并在本地运行函数代码,我正在使用现成的Azure函数项目模板。我试图让一个由计时器触发的Azure函数使用输出绑定向服务总线队列发送消息,但看起来WebJob SDK无法将输出绑定到字符串类型

绑定

 "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”绑定到类型字符串&。确保参数正确 绑定支持类型。如果您使用的是绑定扩展 (例如服务总线、计时器等)确保您已拨打 启动代码中扩展的注册方法(例如。 config.UseServiceBus()、config.UseTimers()等)


我是否缺少设置中的一个步骤,或者服务总线绑定是否真的不支持
输出
参数的字符串

看起来您缺少
服务总线
的绑定属性。我只使用了
ICollector
类型,而不是
out字符串
,但这两种方式都不重要

[FunctionName("TimerTriggerCSharp")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer,
                       TraceWriter log,
                       [ServiceBus("%QueueName%", Connection = "ServiceBusConnection", EntityType = Microsoft.Azure.WebJobs.ServiceBus.EntityType.Queue)] out string msg)
{
   msg = "My message";
}
要使用VS2017预览工具在本地运行,您还需要在
local.settings.json
中定义以下本地设置,以匹配您的
ServiceBus
属性

{
  "Values": {
     "ServiceBusConnection" : "Endpoint=sb://.....your connection",
     "QueueName": "my-service-bus-queue
   }
}

您使用什么参考来获取ServiceBus?