For an Event Hubs Python consumer using an HTTP proxy, configure the SDK’s proxy dictionary and WebSocket transport when constructing the client:

from azure.eventhub import EventHubConsumerClient, TransportType

client = EventHubConsumerClient(
    fully_qualified_namespace=namespace,
    eventhub_name=eventhub_name,
    consumer_group='$Default',
    credential=credential,
    transport_type=TransportType.AmqpOverWebsocket,
    http_proxy={
        'proxy_hostname': 'proxy.example',
        'proxy_port': 8080,
    },
)

The namespace, Event Hub name and credential are the application’s existing service configuration. Continue with its receive callbacks and normal client-close lifecycle.

This dictionary describes the intermediary directly. It is not the http/https destination-scheme map accepted by Requests. For a public Event Hubs namespace where public intermediaries are permitted, the HTTP proxy list supplies candidates for the no-account hostname and port fields. Add username and password keys if the intended proxy account is required.

AMQP over WebSockets uses the service’s port 443, whereas the ordinary AMQP transport uses 5671. The proxy still needs to permit the resulting connection to the Event Hubs namespace.

A token credential can make separate HTTP requests while obtaining tokens. Configure its supported transport as required when that authentication path also needs the proxy.

Mikanda mikatakata