繁体   English   中英

Azure功能 - c# - 带有Blob绑定的ServicebusTrigger

[英]Azure Function - c# - ServicebusTrigger with Blob binding

我有一个带有servicebus触发器和blob输入绑定的python函数。 blob的名称与队列消息的内容匹配。 我的function.json文件看起来像这样:

{
"bindings": [
    {
    "type": "serviceBusTrigger",
    "name": "inputMessage",
    "connection": "Omnibus_Validation_Listen_Servicebus",
    "queueName": "validation-input-queue",
    "accessRights": "listen",
    "direction": "in"
    },
    {
    "type": "blob",
    "name": "inputBlob",
    "path": "baselines/{inputMessage}",
    "connection": "Omnibus_Blob_Storage",
    "direction": "in"
    }
],
"disabled": false
}

它的工作就像一个魅力。

我将使用相同的绑定创建一个C#函数,但它似乎不起作用。 我使用了相同的function.json文件。

我有一个project.json文件:

{
    "frameworks": {
        "net46": {
            "dependencies": {
                "WindowsAzure.Storage": "8.5.0"
            }
        }
    }
}

我的run.csx文件看起来像这样:

public static void Run(string inputMessage, Stream inputBlob, TraceWriter log)
{
    log.Info($"C# ServiceBus queue trigger function processed message: {inputMessage}");
}

保存/运行该功能时,收到此错误:

函数($ import-baseline)错误:Microsoft.Azure.WebJobs.Host:错误索引方法'Functions.import-baseline'。 Microsoft.Azure.WebJobs.Host:'inputMessage'不存在绑定参数。

对于这种绑定,python和c#sdk之间有什么区别吗?

如果我在function.json文件baselines\\{inputMessage}输入blob路径与baselines\\{serviceBusTrigger}baselines\\{inputMessage}绑定在一起,我也可以在我身边重现它。

我不确定当前是否支持集成输入servicebus队列和输入blob。 我们可以向Azure功能团队提供反馈

如果Azure 存储队列是可接受的,我们可以使用Azure存储队列触发器来执行此操作。 我测试它在我身边,它正常工作。

在此输入图像描述

run.csx文件

using System;
using System.Threading.Tasks;

public static void Run(string myQueueItem, Stream inputBlob, TraceWriter log)
{
    log.Info($"C# storage queue trigger function processed message: {myQueueItem}");
    StreamReader reader = new StreamReader(inputBlob);
    string text = reader.ReadToEnd();
    log.Info(text);
}

function.json

{
  "bindings": [
    {
      "type": "blob",
      "name": "inputBlob",
      "path": "incontainer/{queueTrigger}",
      "connection": "testweblog_STORAGE",
      "direction": "in"
    },
    {
      "type": "queueTrigger",
      "name": "myQueueItem",
      "queueName": "myqueue",
      "connection": "testweblog_STORAGE",
      "direction": "in"
    }
  ],
  "disabled": false
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM