我有下面的代码来捕获所有到达的消息
IoT Hub
[FunctionName("device-message--funcapp-v2")]
public static void Run([IoTHubTrigger("testhub",
Connection = "IoTHubEventEndPoint",
ConsumerGroup = "ActualConsumerGroup")]EventData message,
ILogger log)
{
log.LogInformation($"C# IoT Hub trigger:
{Encoding.UTF8.GetString(message.Body.Array)}");
}
这可以正常工作,但现在我不想硬编码
ConsumerGroup
. 所以我在下面添加了configuraiton条目
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"EventHub": "",
"CosmosDb": "",
"ConfigurationConsumerGroup": "ActualConsumerGroup"
}
}
并将代码更改如下
[FunctionName("device-message--funcapp-v2")]
public static void Run([IoTHubTrigger("testhub",
Connection = "IoTHubEventEndPoint",
ConsumerGroup = "ConfigurationConsumerGroup")]EventData message,
ILogger log)
但它失败了。
[1/18/2019 9:47:11 am]microsoft.azure.eventhubs:找不到消息实体“iothub-ns-testhub-945897-3A6F492CC4:eventhub:lctesthub~8191 configurationConsumerGroup”。