简体   繁体   English

Azure function IoTHub:错误索引方法值不能是 null。 (参数“连接字符串”)

[英]Azure function IoTHub: Error indexing method Value cannot be null. (Parameter 'connectionString')

Am trying to set a trigger from an Azure function to read all data that comes from my IoT hub.我试图从 Azure function 设置触发器来读取来自我的 IoT 中心的所有数据。 For that, I followed this tutorial .为此,我遵循了本教程

After setting the connection string inside my local settings, when I try to launch my function, I get the following error:在本地设置中设置连接字符串后,当我尝试启动 function 时,出现以下错误:

The 'functionName' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.functionName'. “functionName”function 出错:Microsoft.Azure.WebJobs.Host:错误索引方法“Functions.functionName”。 Microsoft.WindowsAzure.Storage: Value cannot be null. Microsoft.WindowsAzure.Storage:值不能为 null。 (Parameter 'connectionString'). (参数'connectionString')。

I have tried to add the endpoint as a servicebus, or directly as a hostname, but in both I have the same error.我尝试将端点添加为服务总线,或直接添加为主机名,但两者都有相同的错误。

  • As ServiceBus: Endpoint=sb://{hubname}.servicebus.windows.net/;SharedAccessKeyName={keyname};SharedAccessKey={accesskeyname};作为 ServiceBus: Endpoint=sb://{hubname}.servicebus.windows.net/;SharedAccessKeyName={keyname};SharedAccessKey={accesskeyname};
  • As hostname: HostName={hostName}.azure-devices.net;SharedAccessKeyName={keyname};SharedAccessKey={accesskeyname}作为主机名: HostName={hostName}.azure-devices.net;SharedAccessKeyName={keyname};SharedAccessKey={accesskeyname}

To add further clarify, I will show my implementation:为了进一步澄清,我将展示我的实现:

local.settings.json local.settings.json

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "",
        "FUNCTIONS_WORKER_RUNTIME": "java",
        "app_trigger_hub_name": "{hubname}",
        "app_trigger_connection": "Endpoint=sb://{hubname}.servicebus.windows.net/;SharedAccessKeyName={accessKey};SharedAccessKey={sharedKey}",
    }
}

Azure Function trigger Azure Function 触发器

 @FunctionName("functionName")
  public void eventHubProcessor(
  @EventHubTrigger(name = "functionName", eventHubName = "%app_trigger_hub_name%",
  connection = "app_trigger_connection") String message,
  final ExecutionContext context) {
  context.getLogger().info(message);
  }

Credentials from azure来自 azure 的凭证

EDIT编辑

After some trial & error I managed to get the connection using the servicebus, but still not working.经过一些试验和错误后,我设法使用服务总线获得连接,但仍然无法正常工作。 Now when I start the function, I got the following error:现在,当我启动 function 时,出现以下错误:

The listener for function 'Functions.function' was unable to start. function 'Functions.function' 的侦听器无法启动。 Microsoft.Azure.EventHubs.Processor: Encountered error while fetching the list of EventHub PartitionIds. Microsoft.Azure.EventHubs.Processor:获取 EventHub PartitionIds 列表时遇到错误。 System.Private.CoreLib: nodename nor servname provided, or not known. System.Private.CoreLib:提供节点名或服务名,或未知。

First of all, are you using a IoTHub or a EventHub?首先,您使用的是 IoTHub 还是 EventHub? In C# you use the iothub attribute: "IoTHubTrigger".在 C# 中,您使用 iothub 属性:“IoTHubTrigger”。

Eg:例如:

@FunctionName("ehprocessor")
public void eventHubProcessor(
  @IoTHubTrigger(name = "msg",
                  eventHubName = "myeventhubname",
                  connection = "myconnvarname") String message,
       final ExecutionContext context )
       {
          context.getLogger().info(message);
 }
using IoTHubTrigger = Microsoft.Azure.WebJobs.EventHubTriggerAttribute;

And for the connectionString you use the "Event Hub compatible endpoint", that you can find under "Built-in endpoints" in the azure portal.对于 connectionString,您可以使用“事件中心兼容端点”,您可以在 azure 门户的“内置端点”下找到该端点。

I saw your edited part now, have you tried to empty your eventhub container locally?我现在看到了您编辑的部分,您是否尝试在本地清空您的 eventthub 容器? "azure-webjobs-eventhub"? “azure-webjobs-eventhub”? that have solve many wierd errors for me.为我解决了许多奇怪的错误。

暂无
暂无

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

相关问题 Azure Function 应用程序无法运行显示此错误值不能是 null。 java 中的(参数“提供者”) - Azure Function app Not able to run showing this error Value cannot be null. (Parameter 'provider') in java Azure 函数,“System.Private.CoreLib:值不能为 null。(参数‘path1’)。值不能为 null。(参数‘provider’)” - Azure Functions, "System.Private.CoreLib: Value cannot be null. (Parameter 'path1'). Value cannot be null. (Parameter 'provider')" DB错误= ORA-01407:无法更新(“ XXX”。“ XXX”。“ VALUE”)为NULL。 - DB Error=ORA-01407: cannot update (“XXX”.“XXX”.“VALUE”) to NULL. 当将值传递给 DualHashBidiMap 的 getKey 方法时,我得到了空值。 即使它存在......? - When passing value into the getKey method of DualHashBidiMap i am getting null. even though it exists...? Getter方法返回null。 Java MVC - Getter method returns null. Java MVC azure iothub设备状态 - azure iothub device status Swing GUI 出现 IntelliJ 错误“contentPane 无法设置为 null”。 从终端编译时 - Swing GUI with IntelliJ error “contentPane cannot be set to null.” when compiling from terminal 错误消息“ com.mysql.cj.exceptions.WrongArgumentException:数据库URL不能为null。”是什么意思? - What does the error message “com.mysql.cj.exceptions.WrongArgumentException: The database URL cannot be null.” mean? 引发了另一个异常:NoSuchMethodError: The method '[]' was called on null。 flutter 中的错误登录 api - Another exception was thrown: NoSuchMethodError: The method '[]' was called on null. error login api in flutter 主键值不能为null。 领域 - Primary key value must not be null. Realm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM