无法设置 Azure IoT Edge 运行时:主机名无效

Failing to setup Azure IoT Edge runtime: Invalid hostname

我在 Azure 上安装了标准 D2s v3(2 个 vcpus,8 GB 内存)运行,安装了 Python、Docker 和 iotedgectl。

当我运行

iotedgectl setup --connection-string "HostName=***.azure-devices.net;DeviceId=***;SharedAccessKey=***" --auto-cert-gen-force-no-passwords

我收到以下错误

ERROR: Error parsing user input data: Invalid hostname. Hostname cannot be empty or greater than 64 characters: ****.nwq4jyrgm4zejiseat2enywp0h.fx.internal.cloudapp.net.
ERROR: Please fix any input values and re-run 'iotedgectl setup'
ERROR: Errors were observed. Return Code: 1

有什么想法吗?

IoT Edge 运行时需要主机名才能为 Edge Hub 生成 TLS 服务器证书。这在模块和叶设备之间启用了可验证的 TLS 连接(对于网关场景)。根据 RFC3280,SSL 证书的通用名称的最大长度为 64 个字符。 (搜索 ub-common-name-length)。

此错误表明主机名超出了此限制。默认情况下,iotedgectl 工具检测并使用主机的主机名。不幸的是,Azure Windows VM 的主机名很长。

要解决这个问题,您可以像这样设置主机名并绕过自动检测:

iotedgectl setup --connection-string "<conn string>" --auto-cert-gen-force-no-passwords --edge-hostname <a shorter hostname>

如果您有兴趣使用 IoT Edge 作为网关,这里有更多信息:https://docs.microsoft.com/en-us/azure/iot-edge/how-to-create-transparent-gateway