Created
February 14, 2020 09:10
-
-
Save danigian/6888dce397b4fef77c4615adf4faa179 to your computer and use it in GitHub Desktop.
Event Hub authentication with Managed Identities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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