Error in Azure Functions leading to Azure Functions unreachable

KOK LI YING 41 Reputation points
2022-12-29T03:31:08.973+00:00

Hi, I suddenly encountered the error '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)' in Azure Functions leading to 'Azure Functions runtime is unreachable' and it didn't happen before. Can someone explain to me what caused this error and how to solve it. By the way I am doing it on the web instead of VS. Thank you in advance!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,271 questions
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
719 questions
{count} votes

Accepted answer
  1. Matthijs van der Veer 4,376 Reputation points MVP Volunteer Moderator
    2023-01-02T10:00:30.5+00:00

    Thank you for adding more information in the comments of my other answer. I reproduced the error, it's not something you did, it's an error in the Azure Portal! To fix it, follow these steps:

    1. Go to the Configuration of your Function.
    In your Function app, select Configuration on the left (under Settings). You will see the application settings of your function. Locate the key that has your IoT Hub name and the _events_IOTHUB suffix. (e.g. if your hub is named best-hub-ever, look for the key best-hub-ever_events_IOTHUB.

    Click on the Edit icon, you need to copy the text after ;EntityPath=. (The key is best-hub-ever in the screenshot)
    275384-image.png
    2. Go to your **Function (select Functions, then your Function) and go the Code + Test screen.**
    You will see a dropdown, click on it and select function.json
    275375-image.png

    When you do, you will notice the configuration is incorrect. The eventHubName is set to samples-workitems. Change this value to the value you copied in step 1. Click on save.
    275431-image.png
    275355-image.png

    Hit save, restart the Function App for good measure, everything should be working again.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Matthijs van der Veer 4,376 Reputation points MVP Volunteer Moderator
    2022-12-29T10:27:07.653+00:00

    An event hub connection string looks like this:

    Endpoint=sb://somehub-421337-f5aa4abe16.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=ASdhwa883ajhwd/+rX+6m3+FNGoE=;EntityPath=event-hub-name  
    

    At the end, you'll find EntityPath=event-hub-name; this specifies the event hub name. You can leave this out of the connection string if you specify it somewhere else in the Event Hub Trigger binding in your function. You did not specify a programming language, so I'll give the example in C#:

    [FunctionName("EventHubTriggerCSharp")]  
    public void Run([EventHubTrigger("event-hub-name", Connection = "EventHubConnectionAppSetting")] EventData[] eventHubMessages, ILogger log)  
    

    In this binding, the name of the event hub is specified in the trigger "event-hub-name". So you would leave the event hub name out of the connection string. The connection string will become:

    Endpoint=sb://somehub-421337-f5aa4abe16.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=ASdhwa883ajhwd/+rX+6m3+FNGoE=  
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.