Daniel's Tech Blog

Cloud Computing, Cloud Native & Kubernetes

Stream Analytics on IoT Edge – deployment changes

Microsoft released the GA version of Stream Analytics on IoT Edge two weeks ago.

-> https://azure.microsoft.com/en-us/blog/azure-stream-analytics-on-iot-edge-now-generally-available/

Beside the changes with the GA version one is most important. When you deploy the Stream Analytics container onto an edge device you must provide the plan id as an environment variable. The plan id is needed for billing purposes and without the plan id the Stream Analytics container does not operate correctly. The container will be shutdown and restarted again and over again.

pi@rp3-01:~ $ iotedge logs streamanalytics
2018-12-17 12:04:43.938 +00:00 [INF] - Module client initializing ...
2018-12-17 12:04:51.851 +00:00 [INF] - Opened module client connection
...
2018-12-17 12:04:53.369 +00:00 [INF] - Job billing id is invalid or is missing from container environment variable, shutting down...
2018-12-17 12:04:53.370 +00:00 [INF] - Will restart container in one minute.
...

So, how you get the plan id when you are using the IoT Edge Virtual Kubelet provider for IoT Edge deployments with Azure Kubernetes Service?

First you need to create a new IoT Edge deployment in the Azure portal and select the Stream Analytics module.

streamanalyticsiotedge01streamanalyticsiotedge02

Then you publish the Stream Analytics configuration to an Azure Storage account.

streamanalyticsiotedge03

Afterwards you click on the newly added Stream Analytics module.

streamanalyticsiotedge04

Scroll down at the Stream Analytics module configuration blade to find the plan id with its value.

streamanalyticsiotedge05

Now, that we have the plan id we need to edit the ConfigMap item of our IoT Edge deployment.

...
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: streamanalytics
data:
  status: running
  restartPolicy: always
  version: "1.0"
  createOptions: |
    {
      "Env": [
               "PlanId=REDACTED"
      ]
    }
  desiredProperties: |
    {
      "ASAJobInfo": "REDACTED",
      "ASAJobResourceId": "REDACTED",
      "ASAJobEtag": "REDACTED",
      "PublishTimestamp": "12/11/2018 9:00:57 AM"
    }

-> https://github.com/neumanndaniel/kubernetes/blob/master/iotedge/templates/multiarch/tempsensor-asa.yaml

After we edited our deployment template and deployed it to our edge device the Stream Analytics module starts and operates successfully.

pi@rp3-01:~ $ iotedge logs streamanalytics
2018-12-17 12:34:46.412 +00:00 [INF] - Module client initializing ...
2018-12-17 12:34:46.620 +00:00 [INF] - Opened module client connection
...
2018-12-17 12:34:46.956 +00:00 [INF] - Unzip ASA job definition ...
2018-12-17 12:34:46.996 +00:00 [INF] - Initalizing ASA Engine ...
2018-12-17 12:34:51.124 +00:00 [INF] -
=============================Metrics report=============================
 DeserializationError                         :                   0
 OutputEvents                                 :                   0
 InputEvents                                  :                   0
 EarlyInputEvents                             :                   0
 DroppedOrAdjustedEvents                      :                   0
 LateInputEvents                              :                   0
 ConversionErrors                             :                   0
 OutputWatermarkDelaySeconds                  :                   0
 InputEventBytes                              :                 0 B
 Errors                                       :                   0
 InputEventsSources                           :                   0
========================================================================

Posted

in

WordPress Cookie Notice by Real Cookie Banner