[英]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.我尝试将端点添加为服务总线,或直接添加为主机名,但两者都有相同的错误。
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.