skip to Main Content

At first I upgraded the package "Microsoft.Azure.Functions.Worker.Extensions.EventHubs" from version 4.3.0 to 5.1.0.
and I upgraded from the deprecated Microsoft.Azure.EventHubs package to Azure.Messaging.EventHubs.

Then I run the C# function that return 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’).

I have this settings
and checked the EntityPath in connectionString is the same as the EventhubName.

My code:

[FunctionName("FilterFunctionEventhubTrigger")]
public async Task Run(
        [EventHubTrigger(
        "EventhubName",
        Connection = "EventhubConnection",
        ConsumerGroup = "%ConsumerGroup%")] EventData[] events, ILogger log)
{ ... }

Why the low version not return this error?

What need I do to solve this error?

2

Answers


  1. Chosen as BEST ANSWER

    I solved this error by change the 'Eventhubname' to use appsettings bindings.

     [FunctionName("FilterFunctionEventhubTrigger")]
    public async Task Run(
            [EventHubTrigger(
            "EventhubName",
            Connection = "EventhubConnection",
            ConsumerGroup = "%ConsumerGroup%")] EventData[] events, ILogger log)
    { ... }
    

    to

            [FunctionName("FilterFunctionEventhubTrigger")]
    public async Task Run(
            [EventHubTrigger(
            eventHubName: "%EventHubName%", // <------ Provide like this
            Connection = "EventhubConnection",
            ConsumerGroup = "%ConsumerGroup%")] EventData[] events, ILogger log)
    { ... }
    

    more information form https://github.com/Azure/azure-functions-core-tools/issues/3034


  2. Remove the EntityPath=abc part from your connection string.

    I think this error is to remove the situation where it would be ambiguous which one to use.
    Of course in your case the value is the same, but they have done a simpler implementation where they throw an error if the event hub name is specified in different places.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search