1

I have an Azure Java Function App (Java 11, gradle, azure-functions-java-library 1.4.0) that is tied to an event hub trigger. There are parameters that I can inject into the annotation by surrounding with % as per https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-expressions-patterns. The connection isn't using the % since it's a special param that is always taken from the app properties.

When I run my function locally, using ./gradlew azureFunctionsRun it runs as expected. But once it's deployed to an Azure Function App, it complains that it can't resolve the params.

The error in Azure:

2021-05-27T18:25:37.522 [Error] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.EventHubTrigger'. Microsoft.Azure.WebJobs.Host: '%app.eventhub.name%' does not resolve to a value.

The Trigger annotation looks like:

@FunctionName("EventHubTrigger")
    public void run(
        @EventHubTrigger(name = "event",
                connection = "app.eventhub.connectionString",
                eventHubName = "%app.eventhub.name%",
                consumerGroup = "%app.eventhub.consumerGroup%",
                cardinality = Cardinality.MANY)
                List<Event> event,
        final ExecutionContext context
    ) {
        // logic
     }

Locally in local.settings.json I have values for:

 "app.eventhub.connectionString": "Endpoint=XXXX",
 "app.eventhub.name": "hubName",
 "app.eventhub.consumerGroup": "consumerName"

And in Azure for the function app, I have Configuration (under Settings) for each of the above.

Any ideas what I'm missing?

1 Answer 1

2

After some further investigation, I managed to get things working in Azure Function Apps by changing my naming convention, from using . as separators to _.

This ended up working both locally and when deployed:

@FunctionName("EventHubTrigger")
    public void run(
        @EventHubTrigger(name = "event",
                connection = "app_eventhub_connectionString",
                eventHubName = "%app_eventhub_name%",
                consumerGroup = "%app_eventhub_consumerGroup%",
                cardinality = Cardinality.MANY)
                List<Event> event,
        final ExecutionContext context
    ) {
        // logic
     }

With configuration settings in local.settings.json as:

 "app_eventhub_connectionString": "Endpoint=XXXX",
 "app_eventhub_name": "hubName",
 "app_eventhub_consumerGroup": "consumerName"

And corresponding updates made to the App configuration.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.