Unable to connect to event hub using TokenCredential
When attempting to connect to event hub using token credentials I get a timeout from the cancelation token and no response from the event hub service. Sample bellow shows trying to get the event hub properties, I saw the same behavior when trying to send events to event hub. I tried using MSI credentials as in the sample bellow as well as my Azure identity credentials using InteractiveBrowserCredential. When using the InteractiveBrowserCredential, I was prompted for my credentials and entered them, and then received a token cancelation exception after some time. I have testing using Azure.Messaging.EventHubs and Azure.Messaging.EventHubs.Producer .net SDK version 5.7.0 and 5.7.1.
How can I connect to event hub using MSI?
string ednpoint = "{EventHubInstanceName}.servicebus.windows.net";
string eventHubName = "sessionqueue";
string msiClientId = "{MSIClientId}";
var creds= new DefaultAzureCredential(new DefaultAzureCredentialOptions { ManagedIdentityClientId = msiClientId });
var eventHubClient = new EventHubProducerClient(ednpoint, eventHubName, creds);
using (var cts = new CancellationTokenSource(TimeSpan.FromMinutes(2)))
{
var properties = await eventHubClient.GetEventHubPropertiesAsync(cts.Token).ConfigureAwait(false);
}