417 - The device's deployment configuration is not setの対処方法

事象

IoT HubでIoT Edge Deviceを作り、(IoT Edge DeviceにModule追加せずに)エッジデバイスでIoT Edgeランタイムを起動すると、IoT Edge DeviceのEdge Runtime Responseに417 - The device's deployment configuration is not setというエラーが表示されます。

f:id:matsujirushix:20180416212245p:plain

また、エッジデバイスでedgeAgentとedgeHubの2つのDockerコンテナが起動するはずなのが、edgeAgentしか起動しません。

pi@raspberrypi:~ $ docker ps
CONTAINER ID        IMAGE                                      COMMAND                  CREATED             STATUS              PORTS               NAMES
c1a8c72c3ce1        microsoft/azureiotedge-agent:1.0-preview   "/usr/bin/dotnet Mic…"   24 hours ago        Up 23 hours                             edgeAgent
pi@raspberrypi:~ $

edgeAgentのログで、ConfigEmptyExceptionが発生していることが分かります。

2018-04-16 11:52:08.164 +00:00 [ERR] - Error refreshing edge agent configuration from twin.
Microsoft.Azure.Devices.Edge.Agent.Core.ConfigSources.ConfigEmptyException: This device has an empty configuration for the edge agent. Please set a deployment manifest.
   at Microsoft.Azure.Devices.Edge.Agent.IoTHub.EdgeAgentConnection.UpdateDeploymentConfig() in /opt/vsts/work/1/s/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/EdgeAgentConnection.cs:line 171
   at Microsoft.Azure.Devices.Edge.Agent.IoTHub.EdgeAgentConnection.<RefreshTwinAsync>d__20.MoveNext() in /opt/vsts/work/1/s/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/EdgeAgentConnection.cs:line 124
2018-04-16 11:52:10.378 +00:00 [INF] - Updated reported properties

原因

これは、IoT Edgeランタイムに必要な設定(edgeAgentに対するModuleTwin?)が無いことで発生しています。

対処方法

次の操作でIoT Edgeランタイムの設定を作成すると直ります。

  1. IoT Hubにある、IoT Edge DeviceのSet Modulesをクリック
  2. Add Modules画面が表示されるので、Nextをクリック
  3. Specify Routes画面が表示されるので、Nextをクリック
  4. Review Template画面が表示されるので、Submitをクリック

Review Template画面で表示されているJSONが、edgeAgentにModuleTwinで設定されているようです。