Microsoft Azure Event Grid Hybrid Connection Consumer sample for C

Por kishp
Última atualização: 12/06/2018
Editar no GitHub

This contains a C# sample to consume events from Azure Event Grid using an Azure relay hybrid connection listener.


This sample demonstrates how to process event grid events which are delivered to an Azure relay hybrid connection destination.

The above sample uses the Event Grid data plane SDK (Microsoft.Azure.EventGrid) and Azure Relay SDK (Microsoft.Azure.Relay).

Getting Started


  • .NET Core 2.0 or higher

    1. Create an Azure Event Grid topic: You will need to first create an Event Grid topic. The steps are described at Make a note of the topic details.
    2. Create an Azure Relay Hybrid connection. Make a note of the hybrid connection details.
    3. Create an event subscription on the topic(created in step#1) using hybrid connection as a destination (created in step#2) using following azure CLI commands ```azurecli-interactive

    Replace with relay hybrid connection details

    relayazuresubscriptionid= relayrg= relayname= hybridname=

    Replace with topic details

    topicazuresubscriptionid= topicresourcegroup= topicname= eventsubscriptionname=

    az account set --subscription $relayazuresubscriptionid relayid=$(az resource show --name $relayname --resource-group $relayrg --resource-type Microsoft.Relay/namespaces --query id --output tsv) hybridconnectionid="$relayid/hybridConnections/$hybridname"

    az account set --subscription $topicazuresubscriptionid az eventgrid event-subscription create \ --topic-name $topicname \ -g $topicresourcegroup \ --name $eventsubscriptionname \ --endpoint-type hybridconnection \ --endpoint $hybridconnectionid


  • Visual Studio 2017 Version 15.5 or later.

Clone this repository onto your local machine. Compile the samples inside Visual Studio, the required Microsoft Azure Event Grid SDK components will automatically be downloaded from

### Running the Sample

  1. The following are the steps to run the HybridConnectionConsumer sample and see events received on hybrid connection listener:

    a. Load HybridConnectionConsumer project in Visual Studio.

    b. In Program.cs, replace the and with the relay connection string and hybrid connection name that you created in pre-requisites.

    c. Run this application from Visual Studio to listen for Event Grid Events.

    1. Use Event Grid publisher sample( to publisher events to the topic that you created in pre-requisites.
    2. Verify that you received the events in the HybridConnectionConsumer console.


(Any additional resources or related projects)