[QUERY] Unable to connect to EventHub using Managed Identity
See original GitHub issueThe 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:
Is it the case that Microsoft recommends using the older package to use Managed Identity security?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top GitHub Comments
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.
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
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:
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
Good Luck!!!