skip to Main Content

I’m loosely following along this article to develop and debug modules for IoTEdge
https://learn.microsoft.com/en-us/azure/iot-edge/how-to-visual-studio-develop-module?view=iotedge-2020-11

The article leverages the iotedgehubdev which is where, presumably, the configuration exists to expose port 53000.

My question is, without using the simulator or iotedgehubdev tool, how do I configure the port to allow messages to be sent using this type of syntax

curl –header "Content-Type: application/json" –request POST –data ‘{"inputName": "input1","data":"hello world"}’ http://localhost:53000/api/v1/messages

        // Register callback to be called when a message is received by the module
        await ioTHubModuleClient.SetInputMessageHandlerAsync("input1", PipeMessage, ioTHubModuleClient);

        static async Task<MessageResponse> PipeMessage(Message message, object userContext) 
        { 
          .... 
        }

Target environment: Ubuntu, IoTEdge 1.1.4, published via IoTHub pulled from ACR
Development: Windows 11, Visual Studio 2022, debug via SSH to docker module on Ubuntu

Once the module is up and running, I want to send a post request to the module from the Ubuntu machine hosting the module. The module is being published from IoTHub

I’ve looked across many articles for clues on how port 53000 is setup and listening but haven’t found anything that helps so far.

Appreciate the help.

2

Answers


  1. Sending a message is now easy, once your code is running on Simulator, you can send messages by issuing a CURL request to the endpoint you received when starting the Simulator. Please follow below Reference in which we have detailed information about:

    ( curl --header "Content-Type: application/json" --request POST --data '{"inputName": "input1","data":"hello world"}' http://localhost:53000/api/v1/messages)
    

    Even I looked across many articles for clues. How to Set up port 53000 without using the simulator or iotedgehubdev tool. if you want to work without using the simulator or iotedgehubdev.

    you can reach out to Azure Support or Can raise a GitHub Issue.

    You can refer this article( Azure IoT Edge Simulator — Easily run and test your IoT Edge application | by Xavier Geerinck | Medium ) by Xavier Geerinck

    Login or Signup to reply.
  2. We have to build a custom API module which will listen to the port just what the iotedgedev utility is doing, in which ever language you are writing it in.

    1. Create a Rest API.

    2. Use Azure Devices Module Client module with IOTEdge enable in project file.

    3. Create an output in your custom API module and send the message using module client.

    4. Create the route config in you deployment file and provide the output of this module output to the input of another module in the routes section.

    5. Edit: Do not forget to mention the createOptions Portbindings and the Exposed Ports section, like for e.g

            "createOptions": {
              "ExposedPorts": {
                "9000/tcp": {}
              },
              "HostConfig": {
                "PortBindings": {
                  "9000/tcp": [
                    {
                      "HostPort": "9000"
                    }
                  ]
                }
              }
            }
      
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search