3

I'm interested by getting the public IP address of a connected device on Azure IoT Hub.

I've checked the SDK's but I cannot see any method to get it.

My purpose is to geolocate the device by IP (That's not accurate, but works for me!).

Any clues?

datoga
  • 103
  • 8

1 Answers1

1

There seems no such function out-of-box.

A workaround is to save device IP address in device twin and update it when the IP changed.

There is Reported properties in device twin that device app can set and update and the solution backend read and query them.

How to update reported property from device app you can reference this tutorial:

Get started with device twins

Update:

Another option, it is suggesting to store device location in device twin in cloud. Ref: Understand and use device twin.

Rita Han
  • 9,574
  • 1
  • 11
  • 24
  • But the device won't know its own public IP address, it will need to get the public IP address using an external service like http://checkip.dyndns.com, isn't it? – datoga May 18 '18 at 07:59
  • @datoga You can store device location in device twin and update it to azure iot hub instead of using public IP. See my update answer. – Rita Han May 25 '18 at 07:46
  • Thanks Rita, but we don't know the IP location or the device location. Is there any change to get this device location from the device or from the Cloud (using the Azure IoT Hub API)? – datoga May 31 '18 at 09:49
  • 1
    @datoga Unfortunately, I didn't find such API. – Rita Han Jun 01 '18 at 06:57