Connecting EventHubs to API Management

In the previous posts, we looked at:

In the third article of the Azure API Mangement series, my esteemed (highly esteemed) colleage Ali Baloch documented how to front-end Event Hubs with API Management with a next-to-no-code solution. Thank You, Ali.

We're assuming you already have:

Azure API Management allows you to take any backend and invoke any HTTP verb POST/GET/PUT/DELETE requests and also provide security, throttling and scaling capabilities.

EventHubs can be invoked using POST request which has following three main parts: (see MSDN)

Procedure:

Steps:

Create an API and specify web service URL of EH.

  1. http{s}://{serviceNamespace}.servicebus.windows.net/{eventHubPath}/publishers/{deviceId}/messages

  2. (Optional) create a product and add API in the product.

  3. Create a policy for API. This is needed to add SAS security headers. For example

    <policies>

                    <inbound>

                                    <set-header name="Authorization" exists-action="override">

                                                    <value><![CDATA[SharedAccessSignature sr=sb%3a%2f%2fali-eh-ns.servicebus.windows.net%2fali-eh%2fpublishers%2fhome&sig=wnLzBidpLnsJBZQzNpHbRl%2bSdasfdsafa%3d&se=1787325230&skn=SendListenPolicy]]></value>

                                    </set-header>

                                    <set-header name="Content-Type" exists-action="override">

                                                    <value><![CDATA[application/atom+xml;type=entry;charset=utf-8]]></value>

                                    </set-header>

                                    <base />

                    </inbound>

                    <outbound>

                                    <base />

                    </outbound>

    </policies>

    1. Make sure sr and sig are hex encoded and added as CDATA.

      To test the API go to developer portal which looks like following:

      Other useful links:

3 Comments

  • Good one Christoph! On a related note, here is a detailed comparison of Event Hub and Kafka (my first MSDN blog post) - http://blogs.msdn.com/b/opensourcemsft/archive/2015/08/08/choose-between-azure-event-hub-and-kafka-_2d00_-what-you-need-to-know.aspx

  • I set the Authorization the same this example but there is the problem with the value. Why? I set the value with CDATA.

    Thanks

  • I receive the erro 400 "The requested HTTP operation is not supported in an EventHub."

    Any Idea?

Add a Comment

As it will appear on the website

Not displayed

Your website