question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUERY] Unable to connect to EventHub using Managed Identity

See original GitHub issue

The Microsoft.Azure.EventHubs (old) package accepts the connection string Endpoint=sb://mynamespace.servicebus.windows.net/;Authentication=Managed Identity whereas the Azure.Messaging.EventHubs (recommended) package seems to not support this feature.

Azure.Messaging.EventHubs returns the error:

The connection string used for an Event Hub client must specify the Event Hubs namespace host, and a Shared Access Signature (both the name and value) to be valid. The path to an Event Hub must be included in the connection string or specified separately. (Parameter ‘connectionString’)

We can see the error being raised when parsing the connection string here:

https://github.com/Azure/azure-sdk-for-net/blob/379d3fc75376cea465e6cb8bc83c29ea32136d8b/sdk/eventhub/Azure.Messaging.EventHubs/src/EventHubConnection.cs#L504-L507

Is it the case that Microsoft recommends using the older package to use Managed Identity security?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jsquirecommented, Oct 26, 2020

Hi @drdamour. Thank you for your feedback. Azure Function bindings are a separate product that are responsible for their own approach for supporting RBAC integration within the host context.

Currently, the Event Hubs bindings make use of the legacy client which has chosen to take a dependency on the legacy authentication libraries and extend the connection string grammar. The workstream to update these bindings to the current generation of Event Hubs library can be found here, and would be the recommended issue to discuss the planned approach for supporting identity-based authorization.

0reactions
Swing0601commented, Jan 13, 2022

I got the same error message, and looked into the source code, finally figured it out. Hope it will be helpful.

here is the source code, there is condition whether get the connection with Identity or Shared Access https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Config/EventHubClientFactory.cs image

Identity-based connections require “<CONNECTION_NAME_PREFIX>__fullyQualifiedNamespace” property. https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-hubs-trigger?tabs=csharp#identity-based-connections

My issue is caused by CONNECTION_NAME_PREFIX is not correct, the format is AzureWebJobs + connectionName, here is an example, CONNECTION_NAME_PREFIX is “AzureWebJobsmyEventHubConnectionString”, then “<CONNECTION_NAME_PREFIX>__fullyQualifiedNamespace” value is “AzureWebJobsmyEventHubConnectionString___fullyQualifiedNamespace”

function.json: image

BTW, my develop language is Python,

CONNECTION_NAME_PREFIX source code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/extensions/Microsoft.Azure.WebJobs.Extensions.Clients/src/Shared/WebJobsConfigurationExtensions.cs

image

Good Luck!!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

We are not able to connect to eventhub using system ...
We are trying to connect to event hub using managed identity but not able to find the connection string to use for Managed...
Read more >
Troubleshoot connectivity issues - Azure Event Hubs
This article provides information on troubleshooting connectivity issues with Azure Event Hubs.
Read more >
Azure Functions – connect to an Event Hub using a Managed ...
You 1) add a Managed Identity to the Azure Function, 2) give it access to the Secrets or whatever in the Key Vault,...
Read more >
Stream Analytics Query UI portal: Unable to connect to ...
I tried using both Connection String and MI for the input, but am still getting the error. I can send messages to and...
Read more >
Stuck with azure function app in python using managed ...
was used, but when I use that function without any DefaultCredential() , then I get 404 error which says System managed identity is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found