Azure / iotedgedev

The Azure IoT Edge Dev Tool greatly simplifies your Azure IoT Edge development process. It has everything you need to get started and helps with your day-to-day Edge development.
https://aka.ms/iotedgedev
Other
160 stars 69 forks source link

Incorrect or Outdated command to fetch connection string of an iot edge device. #612

Closed pySage closed 10 months ago

pySage commented 10 months ago

Description

image The above screenshots shows the current implement of the function get_device_connection_string. But the correct implementation is as follows: def get_device_connection_string(self, value, iothub, resource_group): self.output.status( f("Retrieving '{value}' connection string..."))

    with output_io_cls() as io:
        result = self.invoke_az_cli_outproc(["iot", "hub", "device-identity", "connection-string", "show" , "--device-id", value, "--hub-name", iothub,
                                             "--resource-group", resource_group],
                                            f("Could not locate the {value} device in {iothub} IoT Hub in {resource_group}."), stdout_io=io)
        if result:
            out_string = io.getvalue()
            data = json.loads(out_string)
            if "cs" in data:
                return data["cs"]
            else:
                return data["connectionString"]

    return ''"

For better readability: image

Expected behavior

The function implementation should be: image

Actual behavior

The current incorrect/outdated implementation is: image

Steps to Reproduce

just run the cmd "iotedgedev iothub setup" and it will fail with following error: image

Environment

iotedgedev, version 2.1.0 Python 3.10.12 pip 22.0.2 (python 3.10) OS: Linux aman-hygenco 6.2.0-32-generic #32~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 18 10:40:13 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

pySage commented 10 months ago

image the issue was with the old version of iotedgedev and pip is not offering the latest version