【问题标题】:Azure Durable Function (Node.JS) error "Microsoft.Azure.WebJobs.Host: Can't bind parameter 'data' to type 'System.String'."Azure 持久函数 (Node.JS) 错误“Microsoft.Azure.WebJobs.Host:无法将参数‘数据’绑定到类型‘System.String’。”
【发布时间】:2020-04-05 11:31:34
【问题描述】:

我正在 Azure Function App 平台上运行一组持久函数(Node.js 编写)。
节点版本为 10,函数运行时为 2。
其中一些配置了触发器:

  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "post"
      ]
    },


{
  "bindings": [
    {
      "name": "name",
      "type": "activityTrigger",
      "direction": "in"
    }
  ],
  "scriptFile": "../.../index.js"
}

从昨天开始,该功能在尝试打开时显示以下错误:

Function (func4/Create) Error: Microsoft.Azure.WebJobs.Host: Error indexing method  
 'Functions.Create'. Microsoft.Azure.WebJobs.Host: Can't bind parameter 'data' to type  
 'System.String'.
    Session Id: 9b3d1a97c12b4c86b751b08ab17c06da

Timestamp: 2019-12-11T19:04:49.345Z

我不知道是什么导致了这种行为。
Kudu 日志也充满了相同的错误,但没有详细信息。

更新(依赖):

 "dependencies": {
    "axios": "^0.19.0",
    "durable-functions": "^1.3.1",
    "moment": "^2.24.0",
    "momentjs": "^2.0.0",
    "request": "^2.88.0",
    "request-promise-native": "^1.0.8",
    "xml-js": "^1.6.11"
  },
  "devDependencies": {
    "@azure/functions": "^1.0.2-beta2",
    "typescript": "^3.3.3"
  }

【问题讨论】:

    标签: javascript node.js azure azure-functions azure-durable-functions


    【解决方案1】:

    问题出在 data 名词中,这似乎是 Azure Functions 中的保留字。
    当我将名称从 data 更改为另一个名称(此处为 context)时,错误消失了:

    {
      "bindings": [
        {
          "name": "context",
          "type": "activityTrigger",
          "direction": "in"
        }
      ],
      "scriptFile": "../dist/Container/index.js"
    }
    

    不幸的是,此信息没有记录在任何地方,我在尝试测试不同的假设时得到了线索。

    【讨论】:

    【解决方案2】:

    请注意 Azure durable functions 不支持 typescript

    如果你使用 JavaScript,它可以支持 Azure 持久函数。

    看看Offical doc

    【讨论】:

    • 好吧,如果你查看最初的帖子,函数运行时间是 2。另外,尽管函数是用 typescript 编写的,但 typescript 编译器是在部署之前执行的,部署文件是纯 js。在任何情况下,此错误都与程序集无关。
    • @Sergey 很抱歉没有注意到您的运行时版本,我修改了我的答案。但是请注意,您的函数仍然是用打字稿编写的。你以前用打字稿写过持久函数吗?除非文档有问题,否则除 C#、JavaScript 和 F# 之外编写的 azure function app 应该无法实现持久函数。 Python 也不支持持久函数。
    • 请看here。当编译为 Javascript (Supported through transpiling to JavaScript.) 时,Typescript 被支持为 2.x 运行时的 GA。这正是我运行 npm build 命令时发生的情况(tsc 编译器在 'dist' 目录中创建纯 js 文件,然后部署到 Function App)。
    • @Sergey 嗨,谢尔盖。非常感谢您的解释,我对天蓝色持久功能支持的理解可能是错误的。如果你解决了这个问题,你可以将你的答案标记为这个问题的答案。这将帮助遇到同样问题的其他人。感谢您的耐心等待。
    猜你喜欢
    • 2019-07-13
    • 1970-01-01
    • 1970-01-01
    • 2021-12-30
    • 1970-01-01
    • 2020-09-24
    • 1970-01-01
    • 2017-10-29
    • 2021-08-16
    相关资源
    最近更新 更多