Azure IoT中心(事件中心)触发器:未找到有效的帐户信息组合

Azure IoT中心(事件中心)触发器:未找到有效的帐户信息组合,azure,azure-functions,azure-iot-hub,Azure,Azure Functions,Azure Iot Hub,我是Azure新手,目前正在研究物联网中心的快速启动 目前为止,将遥测数据从设备发送到物联网集线器,并通过后端应用程序读取 我安装了vs代码扩展,并成功完成了Azure函数的HTTP触发器示例 在下一步中,我尝试配置IoT Hub(事件中心)Azure功能。在本地测试时,这会导致以下错误: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.funcexample'. Microsoft.WindowsAzure.Stor

我是Azure新手,目前正在研究物联网中心的快速启动

目前为止,将遥测数据从设备发送到物联网集线器,并通过后端应用程序读取

我安装了vs代码扩展,并成功完成了Azure函数的HTTP触发器示例

在下一步中,我尝试配置IoT Hub(事件中心)Azure功能。在本地测试时,这会导致以下错误:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.funcexample'. Microsoft.WindowsAzure.Storage: No valid combination of account information found.
我在
local.settings.json
中添加了物联网中心的
事件中心兼容端点
字符串:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "Endpoint=sb://.../;SharedAccessKeyName=iothubowner;SharedAccessKey=...;EntityPath=...",
    "FUNCTIONS_WORKER_RUNTIME": "node"
  }
}
我注意到
SharedAccessKey
通过
az iot hub策略显示--name服务--query primaryKey--hub name{您的iot hub name}
与Azure门户中的密钥不匹配。两个键都会导致上述警告。 Edit1:
SharedAccessKey
s对于服务和所有者是不同的

Edit2:我认为我的主要问题与连接字符串有关。需要什么连接字符串以及它的格式。以及,连接字符串应该放在哪个文件/设置中

以下是其他相关文件(大部分未触及)。 function.json

{
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "IoTHubMessages",
      "direction": "in",
      "eventHubName": "samples-workitems",
      "connection": "AzureWebJobsStorage",
      "cardinality": "many",
      "consumerGroup": "$Default"
    }
  ]
}
index.js

module.exports = function (context, IoTHubMessages) {
    context.log(`JavaScript eventhub trigger function called for message array: ${IoTHubMessages}`);
    
    IoTHubMessages.forEach(message => {
        context.log(`Processed message: ${message}`);
    });

    context.done();
};
host.json:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[2.*, 3.0.0)"
  }
}
proxies.json:

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {}
}
package.json:

{
  "name": "funcexample",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start": "func start",
    "test": "echo \"No tests yet...\""
  },
  "dependencies": {},
  "devDependencies": {}
}

我遗漏了什么?

我对生产和开发中的Azure功能(在本地测试)中的存储帐户、实际的物联网中心及其连接字符串有一些普遍的误解

为了在本地进行测试,我通过
npm install-g azurite
安装了本地存储模拟器,并对
local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "AzureWebJobsDashboard": "UseDevelopmentStorage=true",
    "ConnectionString": "Endpoint=sb://.../;SharedAccessKeyName=...;SharedAccessKey=...;EntityPath=...",
    "FUNCTIONS_WORKER_RUNTIME": "node"
  }
}
function.json

{
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "IoTHubMessages",
      "direction": "in",
      "eventHubName": "samples-workitems",
      "connection": "ConnectionString",
      "cardinality": "many",
      "consumerGroup": "$Default"
    }
  ]
}

尝试添加
@azure/event hubs
包,有关连接字符串的相关信息,请参阅此链接[