简体   繁体   中英

Exposing Azure IoT Edge EFlow ports to host machine(Windows)

  1. I have an API module running in the linux VM (as Iot Edge EFLOW) which is exposing certain port, let's take 8000. This module is the one which is taking the data and sending it to the other iot edge custom modules for processing before sending it to the iot hub.
  2. I have created 2 modules, 1 Web API .net6) and 1 CSharpModule.netcoreapp3.1, which comes out of the box when creating using VS Code).
  3. I deployed both the modules and they ran successfully and i was able to do a curl inside the linux kernel(EFlow kernel) with my REST calls. eg curl -XPOST -H "Content-type: application/json" -d '{ "date":"2022-04-19T11:17:06Z", "temperature":"10", "pressure":"120", "batterylife":"100" }' 'http://localhost:8000/edgesensor'

Now, the problem statement, I would like to call the same endpoint via my windows host and reach that port 8000, which is not happening and I getting a connection refused.

The configurations I have for that API module is as below.

         "createOptions": {
            "ExposedPorts": {
              "8000/tcp": {}
            },
            "HostConfig": {
              "PortBindings": {
                "8000/tcp": [
                  {
                    "HostPort": "8000"
                  }
                ]
              }
            }
          }

I have tried looking at the samples provided, like below github link for EFlow.

https://github.com/Azure/iotedge-eflow

But this sample makes the iot edge act as a device gateway and the console app that is calling it as a child device.

  1. Is this the only way to connect to the EFlow IoT Edge device, that is to make it act as a gateway or can it be called in the manner I am trying to call?

  2. Port forwarding is one such method as well. but is there something in the config that Azure IoT Edge module offers to do this, am I missing something?

Any inputs appreciated.

Cheers!

If you want to connect to the port directly from the Windows host OS, you can use the EFLOW VM IP address + the port. To get the EFLOW VM IP, you can use the Get-EflowVmAddr .

If you want to connect from a different Windows device, there are two possible scenarios:

  • Internal Switch with Win Server - you can use Static IP instead of DHCP and then use port forwarding to that static IP. For example, imagine your EFLOW VM has the 172.20.1.2 address, and you want to forward the port 8080, then on the Windows host OS you should run the following command: netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=8080 connectaddress=172.20.1.2

  • Default Switch with Win Client- you can use the EFLOW VM hostname + "mshome.net" instead of the static IP. For example, imagine your EFLOW VM has the "DESKTOP-TEST-EFLOW" hostname, and you want to forward the port 8080, then on the Windows host OS you should run the following command: netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=8080 connectaddress=DESKTOP-TEST-EFLOW.mshome.net

Thanks, Francisco

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM