MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.2k stars 21.35k forks source link

Azure function IoT Hub template missing documentation #108517

Open the-programmer opened 1 year ago

the-programmer commented 1 year ago

First off, this is probably not the (fully) correct location but I should be 90% of the way there.

Today I was attempting to create a Azure function that connects to the IoT Hub. However after the deployment I got the following error message.

Azure.Messaging.EventHubs: The path to an Event Hub may be specified as part of the connection string or as a separate value, but not both.  Please verify that your connection string does not have the `EntityPath` token if you are passing an explicit Event Hub name. (Parameter 'connectionString').

Steps to reproduce.

If you try to run this function app, you'll get the above error.

In order to fix this error you have to open the "function.json" file, set the "eventHubName" from "samples-workitems" to the value provided by the IoT Hub under "Build-in endpoints"->"Event Hub Details"->"Event Hub-compatible name".

In my opinion would it be great if the template looks like this

//Be sure to update te eventHubName in function.json to the Event Hub-compatible name listed in the IoT Hub
//This can be found under Build-in endpoints > Event Hub Details
using System;

public static void Run(string myIoTHubMessage, ILogger log)
{
    log.LogInformation($"C# IoT Hub trigger function processed a message: {myIoTHubMessage}");
}

That way the user at least knows what they have to do in case thy run into issues.

[Edit] Also see this article as my source


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

RamanathanChinnappan-MSFT commented 1 year ago

@the-programmer

Thanks for your feedback! We will investigate and update as appropriate.