I have below code to catch all the messages arrives at 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)}");
}
This works fine as expected, but now I do not want to hard code the ConsumerGroup
. So I added below configuraiton entry in local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"EventHub": "",
"CosmosDb": "",
"ConfigurationConsumerGroup": "ActualConsumerGroup"
}
}
and changed code as below
[FunctionName("device-message--funcapp-v2")]
public static void Run([IoTHubTrigger("testhub",
Connection = "IoTHubEventEndPoint",
ConsumerGroup = "ConfigurationConsumerGroup")]EventData message,
ILogger log)
But it fails.
[1/18/2019 9:47:11 AM] Microsoft.Azure.EventHubs: The messaging entity 'iothub-ns-testhub-945897-3a6f492cc4:eventhub:lctesthub~8191|ConfigurationConsumerGroup' could not be found.
Use ConsumerGroup = "%ConfigurationConsumerGroup%"
to read settings from local.settings.json. Check the doc. Note that the connection property of triggers and bindings is a special case and automatically resolves values as app settings, without percent signs.