Azure IoT Hubにデバイスを登録する

Azure IoT Hubにデバイスを登録する時、WindowsだとDevice Explorerを使用します、Windows以外の場合はiothub-explorerを使用します。

ここでは、LinuxMac OS Xのような非Windowsを対象とします。

前提

  • Node.JSとnpmがインストールされていることが必要です。

iothub-explorerのインストール

$ sudo npm install -g iothub-explorer@latest
$ iothub-explorer help
  • Azure PortalのIoT Hubの設定から、共有アクセスポリシーを選択し、iothubownerの接続文字列をクリップボードにコピーして、つぎのコマンドを実行します。
$ iothub-explorer login "HostName=<my-hub>.azure-devices.net;SharedAccessKeyName=<my-policy>;SharedAccessKey=<my-policy-key>"
  • new-device-idの部分に登録するデバイスIDを設定します。
$ iothub-explorer create <new-device-id> --connection-string