Skip to content

Instantly share code, notes, and snippets.

@danigian
Created February 14, 2020 09:10
Show Gist options
  • Save danigian/6888dce397b4fef77c4615adf4faa179 to your computer and use it in GitHub Desktop.
Save danigian/6888dce397b4fef77c4615adf4faa179 to your computer and use it in GitHub Desktop.
Event Hub authentication with Managed Identities
//The managed identity needs the Azure Event Hub Data Owner/Sender/Receiver role (depending on what you need to achieve)
static async Task GetEventHubClient()
{
var ehClient = Microsoft.Azure.EventHubs.EventHubClient.CreateWithManagedIdentity(new Uri($"sb://{ehNamespace}.servicebus.windows.net"), entityPath);
await ehClient.SendAsync(new EventData(Encoding.UTF8.GetBytes("Hello from Managed Identity")));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment