Getting started - Managing Event Hub Events using Azure .NET SDK

This code sample will show you how to manage Event Hub Events using Azure SDK for .NET.


This project framework provides examples for the following services:


  • You can find the details for the library here.

Getting Started


You will need the following values to authenticate to Azure

  • Subscription ID
  • Client ID
  • Client Secret
  • Tenant ID

These values can be obtained from the portal, here's the instructions:

Get Subscription ID

  1. Login into your Azure account
  2. Select Subscriptions in the left sidebar
  3. Select whichever subscription is needed
  4. Click on Overview
  5. Copy the Subscription ID

Get Client ID / Client Secret / Tenant ID

For information on how to get Client ID, Client Secret, and Tenant ID, please refer to this document

Setting Environment Variables

After you obtained the values, you need to set the following values as your environment variables


To set the following environment variables on your development system:

Windows (Note: Administrator access is required)

  1. Open the Control Panel
  2. Click System Security, then System
  3. Click Advanced system settings on the left
  4. Inside the System Properties window, click the Environment Variables… button.
  5. Click on the property you would like to change, then click the Edit… button. If the property name is not listed, then click the New… button.

Linux-based OS :



To complete this tutorial:

If you don't have an Azure subscription, create a free account before you begin.


  1. Clone the repository on your machine:
git clone
  1. Switch to the project folder:
cd samples/eventhub/manage-event-hub-events
  1. Run the application with the dotnet run command.
dotnet run

This sample shows how to do following operations to manage Event Hub Events

  • Create a Event Hub namespace and an Event Hub in it.
  • Create Authorization Rule and get key.
  • Send events to Event Hub and read them.

More information

The Azure Compute documentation includes a rich set of tutorials and conceptual articles, which serve as a good complement to the samples.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.