Connecting to Azure Event Hubs or Azure Service Bus Using REST

Two of the most widely used messaging services in the Azure Cloud platform are Azure Event Hubs and Azure Service Bus. Architects and developers take advantage of these messaging services to scale and extend their applications into more advanced cloud services in Azure, such as machine learning, real-time data analytics and data science.

Azure Event Hubs is a fully managed, real-time data ingestion service; it is often used to stream millions of events from multiple sources and build multiple data pipelines.

Azure Service Bus is a highly reliable cloud messaging service that connects applications with services. It offers asynchronous operations between server and clients, as well as other messaging capabilities such as pub/sub with queues and topics.

Azure Event Hubs is more suitable with requirements to ingest massive volume of data, where Azure Service Bus is more suitable for enterprise messaging needs.

In the 9.8.0 release of Solace's PubSub+ event broker, within a REST delivery point (RDP) an Azure administrator can now set up a service account to establish OAuth authentication between Azure and the PubSub+ broker, designating proper application registrations and permissions.

The OAuth client authentication flow enables PubSub+ event brokers to get an access token from the authorization server using primary credentials (client id and client secret) so that there are no redirects or refresh tokens. These credentials are usually associated with an application rather than a person, making it more suitable and secured for governance on permission.

Refer to OAuth Client Authentication for more information.

Goals

The goal of this tutorial is to demonstrate how to set up an OAuth 2.0 client authentication in PubSub+ event broker to send messages to Azure Event Hubs from a remote connection. This tutorial will show you how to:

  • Configure the event broker to set up RDPs with OAuth client authentication to Azure Event Hubs or Service Bus
  • Send messages to Azure Event Hubs using the Try Me! functionality built into the PubSub+ Broker Manager
  • Review messages sent into Event Hubs under blog storage

Prerequisites

Connecting to Azure Event Hubs

In the 9.8.0 release of Solace's PubSub+ event broker, new REST Connector wizard can help you set up and configure integrations to various cloud platforms and their services.

This example shows how to set up OAuth client authentication with Microsoft Azure.

  1. Log into the PubSub+ Broker Manager.
  2. Launch the connector Click-to-Connect Wizard (refer to Creating a REST Connector with Click-to-Connect).
  3. Click Microsoft Azure.

  4. Click Azure Event Hubs then click Authenticate.

  5. Provide a name for the connector and enter the Client ID and Client Secret provided by Azure.

    You can get the client ID from the Azure console in the Overview section. The client ID is the application ID which an Azure Event Hub has registered.

    Client secrets are located in the Certificates & secretssection, however, you may need to obtain this from your Azure Administrator because it is only available when the application is created.

  6. Once the authentication has been established, enter the Azure Namespace Host , Event Hubs Instance name, and configure the client profile accordingly.

    The Azure Namespace Host is the Host name of the Event Hubs Namespace.

    You can get the Event Hubs instance name from the Azure console home screen, in this example, dw-test is the Event Hubs instance name.

  7. Choose the queue subscription. This example uses default.

  8. Click Create and Enable Connector to finalize the connector creation.

Connecting to Azure Service Bus

To connect to Azure Service Bus, you can follow many of the same steps you used to connect to Event Hubs, except that you need to use the application and its client ID and secrets for the application setup for Azure Service Bus.

  1. Log into the PubSub+ Broker Manager.
  2. Launch the connector Click-to-Connect Wizard (refer to Creating a REST Connector with Click-to-Connect).
  3. Click Microsoft Azure.
  4. Click Azure Service Bus then click Authenticate.
  5. Provide a name for the connector and enter the Client ID and Client Secret provided by Azure.

    You can get the client ID from the Azure console in the Overview section. The client ID is the application ID which an Azure Service Bus has registered.

    You must obtain the client secret from your Azure Administrator because it is only available when the application is created.

  6. Once the authentication has been established, enter the Azure Namespace Host, Service Bus Entity, and configure the client profile accordingly.

    For the Azure Namespace Host, use the Service Bus Namespace Host name.

    For the Service Bus Entity, use the queue name that you have configured for this Service Bus.

  7. Choose the queue subscription.

  8. Click Create and Enable Connector to finalize the connector creation.

Setting Up Azure Event Hubs Blog Storage

After configuring a connection to your Azure Event Hubs instance, you can set up a blog storage to receive the message. In addition, you can use a Python script to read back what is written into the storage.

  1. Set up a container for your Azure Event Hubs.

  2. Use the PubSub+ Broker Manager Try Me! application to send a message to the default subscription.

  3. Use a Python script to read back what was written into the blog storage.