Azure/azure-iot-cli-extension

What argument is -l

omar-nav opened this issue · 2 comments

This is autogenerated. Please review and update as needed.

Describe the bug

Instead of using an IoT Hub name; I had passed the certificate as --login argument. What exactly does -l request? Documentation somewhat unclear on this.

Command Name
az iot edge set-modules Extension Name: azure-iot. Version: 0.13.0.

Errors:

The command failed with an unexpected error. Here is the traceback:
IoT Hub connection string has missing property: HostName
Traceback (most recent call last):
  File "/opt/az/lib/python3.8/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 658, in execute
    raise ex
  File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 721, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 692, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.8/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/home/efferent/.azure/cliextensions/azure-iot/azext_iot/operations/hub.py", line 1188, in iot_edge_set_modules
    target = discovery.get_target(
  File "/home/efferent/.azure/cliextensions/azure-iot/azext_iot/common/base_discovery.py", line 289, in get_target
    return self.get_target_by_cstring(connection_string=cstring)
  File "/home/efferent/.azure/cliextensions/azure-iot/azext_iot/iothub/providers/discovery.py", line 50, in get_target_by_cstring
    return IotHubTarget.from_connection_string(cstring=connection_string).as_dict()
  File "/home/efferent/.azure/cliextensions/azure-iot/azext_iot/iothub/models/iothub_target.py", line 23, in from_connection_string
    decomposed = parse_iot_hub_connection_string(cs=cstring)
  File "/home/efferent/.azure/cliextensions/azure-iot/azext_iot/common/_azure.py", line 31, in parse_iot_hub_connection_string
    return _parse_connection_string(cs, validate, "IoT Hub")
  File "/home/efferent/.azure/cliextensions/azure-iot/azext_iot/common/_azure.py", line 21, in _parse_connection_string
    raise ValueError(
ValueError: IoT Hub connection string has missing property: HostName

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here...
  • az iot edge set-modules --login {} --device-id {} --content {} --only-show-error -o {}

Expected Behavior

Environment Summary

Linux-4.15.0-161-generic-x86_64-with-glibc2.27, Ubuntu 18.04.6 LTS
Python 3.8.12
Installer: DEB

azure-cli 2.34.1

Extensions:
azure-iot 0.13.0

Dependencies:
msal 1.16.0
azure-mgmt-resource 20.0.0

Additional Context

Hi @omar-nav , -l as an alias for --login corresponds to an IoT Hub connection string. Idea being you do not need to use your Azure AD credentials (via az login) to interact with the target IoT Hub. The ValueError hints at this IoT Hub connection string has missing property: HostName. For setting modules on an edge device (the command you are using), the desired content payload gets sent to IoT Hub, then IoT Hub will communicate with your edge device to apply updates.

A certificate is not needed in this particular flow.

Let us know if you have more questions about this.