Azure IoT Hub device connect through Application Gateway

Craig Webb 5 Reputation points
2025-05-28T04:54:22.17+00:00

I have a requirement for allowing a c# service deployed to a customer PC to connect to our Azure components.
Currently they are all routed through an Application Gateway.

I would like to expand our features in Azure and add IoT Hub so the service can also be a device connecting to IoT Hub.

Is it possible to route the IoT Hub traffic through Application Gateway.
I have tried MQTT over Websocket, and turning on the Preview feature off Application Gateway to proxy TCP and TLS traffic.
Thus far I have not been able to establish a connection when routing through Application Gateway.

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
{count} votes

2 answers

Sort by: Most helpful
  1. VSawhney 880 Reputation points Microsoft External Staff Moderator
    2025-05-28T08:23:59.24+00:00

    Hello Craig Webb,

    It sounds like you're trying to connect a C# service on a customer PC to Azure IoT Hub while routing through an Application Gateway.

    This isn’t directly supported because the IoT Hub uses specific protocols that the Application Gateway isn't designed to handle effectively, especially with MQTT and WebSocket communications.

    Here are a few things you can try:

    1. Direct Connection: Instead of routing through the Application Gateway, consider allowing direct connections to the IoT Hub from your C# service. This is the simplest way to ensure that the service can communicate effectively using MQTT or MQTT over WebSocket. https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-protocols
    2. Use IoT Edge as field Gateway: If your architecture needs to use an Application Gateway for other reasons (e.g., security, logging), consider deploying an IoT Edge device that can act as a proxy. The IoT Edge device would be responsible for managing the connection from downstream devices to the IoT Hub.

    https://learn.microsoft.com/en-us/azure/iot-edge/iot-edge-as-gateway

    Hope this helps you get closer to a solution!
    Thank you!

    0 comments No comments

  2. Sander van de Velde | MVP 36,941 Reputation points MVP Volunteer Moderator
    2025-05-28T10:41:32.1333333+00:00

    Hello @Craig Webb ,

    welcome to this moderated Azure community forum.

    The Azure IoT Hub offers a cloud gateway for devices using protocols like MQTT, AMQP and the websocket alternatives. Techically, HTTP calls are also supported but this is not recommended because it has functional limitations . Do not use the HTTP calls.

    I have never encountered the combination of an Application Gateway and the Azure IoT Hub.

    The Azure IoT hub has its own mechanisms to eg. load balance (using the separate Device Provisioning Service) or securing the access (eg. using private endpoints), or using the edge solution to separate local traffic with cloud traffic.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.