使用iothub-explorer登录时遇连接字符串缺失SharedAccessKeyName属性问题
解决iothub-explorer登录时的ArgumentError问题
你遇到的这个报错,核心原因是shell把连接字符串里的分号当成了命令分隔符,导致iothub-explorer只收到了连接字符串的一部分,自然会提示缺失SharedAccessKeyName属性。
具体问题分析
你执行的原始命令:
pi@raspberrypi:~ $ iothub-explorer login HostName=roomautomation.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
在bash这类shell环境中,;是用来分隔多个独立命令的符号。所以shell会把你的命令拆成三部分:
iothub-explorer login HostName=roomautomation.azure-devices.netSharedAccessKeyName=iothubownerSharedAccessKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
这样一来,iothub-explorer只拿到了HostName这一段,完全没收到后面的SharedAccessKeyName和SharedAccessKey,所以才会抛出缺失属性的错误。
修复方法
把整个连接字符串用引号包裹,让shell把它当作一个完整的参数传递给iothub-explorer,两种引号都可以用:
方法1:使用双引号
pi@raspberrypi:~ $ iothub-explorer login "HostName=roomautomation.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
方法2:使用单引号
pi@raspberrypi:~ $ iothub-explorer login 'HostName=roomautomation.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
执行上面任意一种命令,应该就能正常完成登录了。如果还是报错,可以再检查下连接字符串里的参数拼写有没有错误,比如SharedAccessKeyName有没有写错,有没有多余的空格之类的。
内容的提问来源于stack exchange,提问作者zaheer afzal
相关产品推荐
相关产品推荐

