Congratulations!

[Valid RSS] This is a valid RSS feed.

Recommendations

This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.

Source: http://feeds2.feedburner.com/ReneHezser

  1. <?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
  2. xmlns:content="http://purl.org/rss/1.0/modules/content/"
  3. xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  4. xmlns:dc="http://purl.org/dc/elements/1.1/"
  5. xmlns:atom="http://www.w3.org/2005/Atom"
  6. xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  7. xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  8. >
  9.  
  10. <channel>
  11. <title>Blog &#8211; René Hézser</title>
  12. <atom:link href="http://www.hezser.de/blog/feed/" rel="self" type="application/rss+xml" />
  13. <link>https://www.hezser.de/blog</link>
  14. <description>My blog about Cloud, Azure, IoT, Development, SharePoint, Office 365 and other things</description>
  15. <lastBuildDate>Mon, 22 Feb 2021 17:13:46 +0000</lastBuildDate>
  16. <language>en-US</language>
  17. <sy:updatePeriod>
  18. hourly </sy:updatePeriod>
  19. <sy:updateFrequency>
  20. 1 </sy:updateFrequency>
  21. <generator>https://wordpress.org/?v=6.0.3</generator>
  22.  
  23. <image>
  24. <url>https://www.hezser.de/blog/files/cropped-coffee-window-bears-small-32x32.jpg</url>
  25. <title>Blog &#8211; René Hézser</title>
  26. <link>https://www.hezser.de/blog</link>
  27. <width>32</width>
  28. <height>32</height>
  29. </image>
  30. <item>
  31. <title>Simulated Temperature IoT Edge Module</title>
  32. <link>https://www.hezser.de/blog/2021/02/22/simulated-temperature-iot-edge-module/</link>
  33. <comments>https://www.hezser.de/blog/2021/02/22/simulated-temperature-iot-edge-module/#respond</comments>
  34. <dc:creator><![CDATA[René Hézser]]></dc:creator>
  35. <pubDate>Mon, 22 Feb 2021 11:04:01 +0000</pubDate>
  36. <category><![CDATA[IoT]]></category>
  37. <category><![CDATA[IoT Edge]]></category>
  38. <guid isPermaLink="false">https://www.hezser.de/blog/?p=2872</guid>
  39.  
  40. <description><![CDATA[This module gives you the flexibility to have multiple sensors sending from one module. This can be configured by the InstanceCount. The existing solution allows you to set the send interval in seconds only. With this solution, you can specify this in milliseconds.]]></description>
  41. <content:encoded><![CDATA[
  42. <p>Me: Yeah! Another Simulated Temperature Sensor solution. </p>
  43.  
  44.  
  45.  
  46. <p>You: Hold on. Why do you create another one again?</p>
  47.  
  48.  
  49.  
  50. <p>Me: Well, mine is more flexible than the existing ones.</p>
  51.  
  52.  
  53.  
  54. <p>You: OK. Show me</p>
  55.  
  56.  
  57.  
  58. <p>Me: </p><p><pre class="wp-block-preformatted">"SendData": true,
  59. "SendInterval": 500,
  60. "InstanceCount": 10</pre></p>
  61.  
  62.  
  63.  
  64. <p>You: <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f97a.png" alt="🥺" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
  65.  
  66.  
  67.  
  68. <p>Me: <strong>This module gives you the flexibility to have multiple sensors sending from one module. This can be configured by the InstanceCount. The existing solution allows you to set the send interval in seconds only. With this solution, you can specify this in milliseconds.</strong></p>
  69.  
  70.  
  71.  
  72. <p>You: Now I understand. Thank you</p>
  73.  
  74.  
  75.  
  76. <p>Me: Sure. Feel free to use the code and adjust it to your needs.</p>
  77.  
  78.  
  79.  
  80. <p><a rel="noreferrer noopener" href="https://github.com/ReneHezser/SimulatedTemperatureSensor" target="_blank">ReneHezser/SimulatedTemperatureSensor: An Azure IoT Edge module that simulates temperature/humidity values with a configurable amount of devices and send interval (github.com)</a></p>
  81.  
  82.  
  83.  
  84. <h2>Summary / What&#8217;s this about</h2>
  85.  
  86.  
  87.  
  88. <p>The solution contains a tweaked Simulated Temperature Module for Azure IoT Edge. It continuously creates simulated temperature data and sends that to an Azure IoT Hub.</p>
  89. ]]></content:encoded>
  90. <wfw:commentRss>https://www.hezser.de/blog/2021/02/22/simulated-temperature-iot-edge-module/feed/</wfw:commentRss>
  91. <slash:comments>0</slash:comments>
  92. </item>
  93. <item>
  94. <title>docker-compose vs. CPU limit</title>
  95. <link>https://www.hezser.de/blog/2020/12/27/docker-compose-vs-cpu-limit/</link>
  96. <comments>https://www.hezser.de/blog/2020/12/27/docker-compose-vs-cpu-limit/#respond</comments>
  97. <dc:creator><![CDATA[René Hézser]]></dc:creator>
  98. <pubDate>Sun, 27 Dec 2020 15:12:42 +0000</pubDate>
  99. <category><![CDATA[Docker]]></category>
  100. <guid isPermaLink="false">https://www.hezser.de/blog/?p=2866</guid>
  101.  
  102. <description><![CDATA[That was a painfull learning today 🙁 Best is to blog about it now, so hopefully somebody reads this before (or during) troubleshooting a similar issue. What happened? My home server was running crazy and did not server any requests. Oh well, it decided to reply my ping but not really allowing a SSH session. [&#8230;]]]></description>
  103. <content:encoded><![CDATA[
  104. <p>That was a painfull learning today <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Best is to blog about it now, so hopefully somebody reads this before (or during) troubleshooting a similar issue.</p>
  105.  
  106.  
  107.  
  108. <h2>What happened?</h2>
  109.  
  110.  
  111.  
  112. <p>My home server was running crazy and did not server any requests. Oh well, it decided to reply my ping but not really allowing a SSH session.</p>
  113.  
  114.  
  115.  
  116. <p>So I needed to drag a TV downstairs to connect it via analog cable (fortunately I still found one), connect a keyboard and see that a process <strong>mono-sgen</strong> was eating all CPU <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> But what does it belong to? A <code>ps -ef</code> revealed that it belonged to duplicati &#8211; which is my backup solution.</p>
  117.  
  118.  
  119.  
  120. <p>Great. I found the problem.</p>
  121.  
  122.  
  123.  
  124. <h2>Now let&#8217;s fix it</h2>
  125.  
  126.  
  127.  
  128. <p>I am deploying all my containers with docker-compose and searched for a way to limit the CPU usage. *gnarf* The used version 3.4 does not support the quotas anymore &#8211;> <a rel="noreferrer noopener" href="https://docs.docker.com/compose/compose-file/compose-versioning/#version-3" target="_blank">Compose file versions and upgrading | Docker Documentation</a></p>
  129.  
  130.  
  131.  
  132. <p>When I set the docker-compose version to 2.4 and adjusted my duplicati container like this, It uses half a CPU max.</p>
  133.  
  134.  
  135.  
  136. <pre class="wp-block-code"><code>duplicati:
  137.  image: duplicati/duplicati:beta
  138.  <strong><span class="has-inline-color has-vivid-red-color">cpus: "0.5"</span>
  139.  <span class="has-inline-color has-vivid-red-color">mem_limit: 512m</span></strong>
  140.  container_name: duplicati
  141.  ...</code></pre>
  142.  
  143.  
  144.  
  145. <figure class="wp-block-image size-large"><img width="787" height="39" src="https://www.hezser.de/blog/files/top.png" alt="" class="wp-image-2867" srcset="https://www.hezser.de/blog/files/top.png 787w, https://www.hezser.de/blog/files/top-300x15.png 300w, https://www.hezser.de/blog/files/top-768x38.png 768w" sizes="(max-width: 787px) 100vw, 787px" /></figure>
  146.  
  147.  
  148.  
  149. <h2>Links</h2>
  150.  
  151.  
  152.  
  153. <ul><li><a href="https://www.lifewire.com/linux-top-command-2201163">How to Use the &#8216;top&#8217; Command to Show Running Processes (lifewire.com)</a></li><li><a href="https://www.fosslinux.com/43296/linux-ps-command-with-examples.htm">Linux PS command with examples | FOSS Linux</a></li><li><a href="https://stackoverflow.com/questions/56399794/how-to-limit-memory-usage-in-docker-compose">How to limit memory usage in docker-compose? &#8211; Stack Overflow</a></li></ul>
  154. ]]></content:encoded>
  155. <wfw:commentRss>https://www.hezser.de/blog/2020/12/27/docker-compose-vs-cpu-limit/feed/</wfw:commentRss>
  156. <slash:comments>0</slash:comments>
  157. </item>
  158. <item>
  159. <title>Renew AWS SessionToken and store values in Azure KeyVault</title>
  160. <link>https://www.hezser.de/blog/2020/11/29/renew-aws-sessiontoken-and-store-values-in-azure-keyvault/</link>
  161. <comments>https://www.hezser.de/blog/2020/11/29/renew-aws-sessiontoken-and-store-values-in-azure-keyvault/#respond</comments>
  162. <dc:creator><![CDATA[René Hézser]]></dc:creator>
  163. <pubDate>Sun, 29 Nov 2020 18:47:05 +0000</pubDate>
  164. <category><![CDATA[AWS]]></category>
  165. <category><![CDATA[Azure]]></category>
  166. <category><![CDATA[KeyVault]]></category>
  167. <guid isPermaLink="false">https://www.hezser.de/blog/?p=2860</guid>
  168.  
  169. <description><![CDATA[Why do you need this? Using temporary session tokens sounds like a good way to e.g. import data from S3 in Azure Data Factory, like it is described here Copy data from Amazon Simple Storage Service (S3) &#8211; Azure Data Factory &#124; Microsoft Docs. Azure Data Factory can use secrets stored in Azure KeyVault for [&#8230;]]]></description>
  170. <content:encoded><![CDATA[
  171. <h2>Why do you need this?</h2>
  172.  
  173.  
  174.  
  175. <p>Using temporary session tokens sounds like a good way to e.g. import data from S3 in Azure Data Factory, like it is described here <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/azure/data-factory/connector-amazon-simple-storage-service" target="_blank">Copy data from Amazon Simple Storage Service (S3) &#8211; Azure Data Factory | Microsoft Docs</a>. Azure Data Factory can use secrets stored in Azure KeyVault for authentication (see here <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/azure/data-factory/store-credentials-in-key-vault" target="_blank">Store credentials in Azure Key Vault &#8211; Azure Data Factory | Microsoft Docs</a>). </p>
  176.  
  177.  
  178.  
  179. <p>Anyway, whatever you use case is, you might want to use secrets stored in KeyVault to access AWS resources <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
  180.  
  181.  
  182.  
  183. <h2>Description of the solution</h2>
  184.  
  185.  
  186.  
  187. <p>I&#8217;ve created a sample Azure Function that updates the session token every hour (or manually) on GitHub.</p>
  188.  
  189.  
  190.  
  191. <figure class="wp-block-image size-large"><img src="https://github.com/ReneHezser/RH-TokenRefresh-Function/raw/main/assets/AWS-SessionToken-Function-Architecture.png" alt=""/><figcaption>Architecture overview (not pretty, but hopefully readable)</figcaption></figure>
  192.  
  193.  
  194.  
  195. <p>The sample code is available in this repository <a rel="noreferrer noopener" href="https://github.com/ReneHezser/RH-TokenRefresh-Function" target="_blank">ReneHezser/RH-TokenRefresh-Function: This sample contains an Azure Function (actually two: one is called via Timer every hour, the other one is for manual trigger via HTTP) that uses an AWS user to create Session Tokens. (github.com)</a>.</p>
  196. ]]></content:encoded>
  197. <wfw:commentRss>https://www.hezser.de/blog/2020/11/29/renew-aws-sessiontoken-and-store-values-in-azure-keyvault/feed/</wfw:commentRss>
  198. <slash:comments>0</slash:comments>
  199. </item>
  200. <item>
  201. <title>Count provisioned devices by DPS</title>
  202. <link>https://www.hezser.de/blog/2020/11/04/count-provisioned-devices-by-dps/</link>
  203. <comments>https://www.hezser.de/blog/2020/11/04/count-provisioned-devices-by-dps/#respond</comments>
  204. <dc:creator><![CDATA[René Hézser]]></dc:creator>
  205. <pubDate>Wed, 04 Nov 2020 18:52:52 +0000</pubDate>
  206. <category><![CDATA[Azure]]></category>
  207. <category><![CDATA[Event Grid]]></category>
  208. <category><![CDATA[Event Hub]]></category>
  209. <category><![CDATA[IoT]]></category>
  210. <category><![CDATA[IoT Hub]]></category>
  211. <category><![CDATA[Stream Analytics]]></category>
  212. <category><![CDATA[Uncategorised]]></category>
  213. <category><![CDATA[EventGrid]]></category>
  214. <category><![CDATA[EventHub]]></category>
  215. <category><![CDATA[StreamAnalytics]]></category>
  216. <guid isPermaLink="false">https://www.hezser.de/blog/?p=2845</guid>
  217.  
  218. <description><![CDATA[This post shows a way to find out how many IoT (Edge) devices have been provisioned by a specific enrolment group within the last x minutes. The solution could be much simpler if I just wanted to know how many devices are registering themselves. In this case the build in metrics are enough to get [&#8230;]]]></description>
  219. <content:encoded><![CDATA[
  220. <p>This post shows a way to find out how many IoT (Edge) devices have been provisioned by a specific enrolment group within the last x minutes.</p>
  221.  
  222.  
  223.  
  224. <p>The solution could be much simpler if I just wanted to know how many devices are registering themselves. In this case the build in metrics are enough to get that information.</p>
  225.  
  226.  
  227.  
  228. <figure class="wp-block-image size-large"><img loading="lazy" width="551" height="463" src="https://www.hezser.de/blog/files/image-12.png" alt="" class="wp-image-2849" srcset="https://www.hezser.de/blog/files/image-12.png 551w, https://www.hezser.de/blog/files/image-12-300x252.png 300w" sizes="(max-width: 551px) 100vw, 551px" /><figcaption>IoT Hub Metrics</figcaption></figure>
  229.  
  230.  
  231.  
  232. <p>The use case required a more sophisticated solution that is able to reflect the tenants, identified by tags.</p>
  233.  
  234.  
  235.  
  236. <figure class="wp-block-image size-large"><img loading="lazy" width="634" height="147" src="https://www.hezser.de/blog/files/image-13.png" alt="" class="wp-image-2850" srcset="https://www.hezser.de/blog/files/image-13.png 634w, https://www.hezser.de/blog/files/image-13-300x70.png 300w" sizes="(max-width: 634px) 100vw, 634px" /><figcaption>Solution Architecture</figcaption></figure>
  237.  
  238.  
  239.  
  240. <h2>Device Provisioning Service</h2>
  241.  
  242.  
  243.  
  244. <p>Different Enrolment Groups separate devices in this scenario into Tenants. To be able to identify the customers, an initial tag <strong>CustomerId</strong>  is added to the enrolment group. It is then applied to the devices that are create by DPS in the IoT Hub.</p>
  245.  
  246.  
  247.  
  248. <pre class="wp-block-code"><code>{
  249.  "tags": {
  250.    "CustomerId": "AnotherCustomer"
  251.  },
  252.  "properties": {
  253.    "desired": {}
  254.  }
  255. }</code></pre>
  256.  
  257.  
  258.  
  259. <p>This tag can then be used for e.g. message enrichment. I&#8217;ve written previously about using it: <a href="https://www.hezser.de/blog/2020/05/13/properties-for-iot-messages-in-azure-stream-analytics/" target="_blank" rel="noreferrer noopener">https://www.hezser.de/blog/2020/05/13/properties-for-iot-messages-in-azure-stream-analytics/ (opens in a new tab)</a></p>
  260.  
  261.  
  262.  
  263. <p>The metrics from DPS did not allow me to distinguish the tags/customers. But IoT Hub will make them available and offers events for newly created devices.</p>
  264.  
  265.  
  266.  
  267. <h2>IoT Hub</h2>
  268.  
  269.  
  270.  
  271. <p>Within IoT Hub I created an event subscription, that passed on all necessary events to an EventHub.</p>
  272.  
  273.  
  274.  
  275. <figure class="wp-block-image size-large"><img loading="lazy" width="654" height="740" src="https://www.hezser.de/blog/files/image-14.png" alt="" class="wp-image-2853" srcset="https://www.hezser.de/blog/files/image-14.png 654w, https://www.hezser.de/blog/files/image-14-265x300.png 265w" sizes="(max-width: 654px) 100vw, 654px" /><figcaption>Event Subscription in IoT Hub</figcaption></figure>
  276.  
  277.  
  278.  
  279. <p>The event will include the device twin, which has been prepopulated with the tags specified in the enrolment group.</p>
  280.  
  281.  
  282.  
  283. <figure class="wp-block-image size-large"><img loading="lazy" width="399" height="436" src="https://www.hezser.de/blog/files/image-15.png" alt="" class="wp-image-2856" srcset="https://www.hezser.de/blog/files/image-15.png 399w, https://www.hezser.de/blog/files/image-15-275x300.png 275w" sizes="(max-width: 399px) 100vw, 399px" /><figcaption>Device Twin in IoT Hub</figcaption></figure>
  284.  
  285.  
  286.  
  287. <p>As seen in the architecture diagram, Event Grid has been connected to an Event Hub. #plugandplay <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> It will fire an event with  the documented schema: <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-event-grid#device-created-schema" target="_blank">Azure IoT Hub and Event Grid | Microsoft Docs</a></p>
  288.  
  289.  
  290.  
  291. <h2>Event Hub</h2>
  292.  
  293.  
  294.  
  295. <p>Why the additional Event Hub? Event Grid cannot be used as input for an Azure Stream Analytics Job and Event Hub is the universal connector in this case.</p>
  296.  
  297.  
  298.  
  299. <p>You can use the smallest tier (which is Basic) as there is not a lot of events flowing through it. The default 2 partitions is also fine.</p>
  300.  
  301.  
  302.  
  303. <h2>Stream Analytics Job</h2>
  304.  
  305.  
  306.  
  307. <p>I chose Stream Analytics for the further analysis of the events, because it offers an out-of-the box functionality for queries on time windows: <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/azure/stream-analytics/stream-analytics-window-functions#tumbling-window" target="_blank">Introduction to Azure Stream Analytics windowing functions | Microsoft Docs</a></p>
  308.  
  309.  
  310.  
  311. <p>As you can see, the query is pretty simple and can be adjusted easily.</p>
  312.  
  313.  
  314.  
  315. <figure class="wp-block-image size-large"><img loading="lazy" width="1004" height="338" src="https://www.hezser.de/blog/files/image-10.png" alt="" class="wp-image-2846" srcset="https://www.hezser.de/blog/files/image-10.png 1004w, https://www.hezser.de/blog/files/image-10-300x101.png 300w, https://www.hezser.de/blog/files/image-10-768x259.png 768w" sizes="(max-width: 1004px) 100vw, 1004px" /><figcaption>Azure Stream Analytics Job Query</figcaption></figure>
  316.  
  317.  
  318.  
  319. <p>The example uses a blob storage as output, but you can choose to write to an Azure Function or whatever you want to do with the know how that one customer has onboarded lots of devices in a short period of time.</p>
  320. ]]></content:encoded>
  321. <wfw:commentRss>https://www.hezser.de/blog/2020/11/04/count-provisioned-devices-by-dps/feed/</wfw:commentRss>
  322. <slash:comments>0</slash:comments>
  323. </item>
  324. <item>
  325. <title>Azure IoT Edge on constraint devices</title>
  326. <link>https://www.hezser.de/blog/2020/11/03/azure-iot-edge-on-constraint-devices/</link>
  327. <comments>https://www.hezser.de/blog/2020/11/03/azure-iot-edge-on-constraint-devices/#respond</comments>
  328. <dc:creator><![CDATA[René Hézser]]></dc:creator>
  329. <pubDate>Tue, 03 Nov 2020 07:33:12 +0000</pubDate>
  330. <category><![CDATA[Azure]]></category>
  331. <category><![CDATA[IoT]]></category>
  332. <category><![CDATA[IoT Edge]]></category>
  333. <category><![CDATA[Uncategorised]]></category>
  334. <category><![CDATA[IoTEdge]]></category>
  335. <guid isPermaLink="false">https://www.hezser.de/blog/?p=2827</guid>
  336.  
  337. <description><![CDATA[Introduction In this post I would like to show some tweaks you can (and might need to) apply to influence the behavior of your IoT Edge device, when it comes to message retention on devices that are limited in resources. The setup of this scenario is not uncommon, as it uses a module to retrieve [&#8230;]]]></description>
  338. <content:encoded><![CDATA[
  339. <div class="wp-container-2 wp-block-group"><div class="wp-block-group__inner-container"></div></div>
  340.  
  341.  
  342.  
  343. <div class="wp-container-3 wp-block-group"><div class="wp-block-group__inner-container">
  344. <h2>Introduction</h2>
  345. </div></div>
  346.  
  347.  
  348.  
  349. <p>In this post I would like to show some tweaks you can (and might need to) apply to influence the behavior of your IoT Edge device, when it comes to message retention on devices that are limited in resources.</p>
  350.  
  351.  
  352.  
  353. <p>The setup of this scenario is not uncommon, as it uses a module to retrieve telemetry from machines, parses them in another module and sends the messages to an IoT Hub.</p>
  354.  
  355.  
  356.  
  357. <h2>The problem</h2>
  358.  
  359.  
  360.  
  361. <p>After a while the device is not sending data anymore and is not accessible via SSH. The logs reveal lots of message still in the queue.</p>
  362.  
  363.  
  364.  
  365. <figure class="wp-block-image size-large"><img loading="lazy" width="596" height="261" src="https://www.hezser.de/blog/files/image-3.png" alt="picture with logfile lines like Cleaned up messages from queue for endpoint iothub and messages from message store" class="wp-image-2828" srcset="https://www.hezser.de/blog/files/image-3.png 596w, https://www.hezser.de/blog/files/image-3-300x131.png 300w" sizes="(max-width: 596px) 100vw, 596px" /><figcaption>Lots of messages in the queue in edgeHub logs</figcaption></figure>
  366.  
  367.  
  368.  
  369. <p>But why? And how can I find out what causes the problem?<br><em>Spoiler: Disk full <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /></em></p>
  370.  
  371.  
  372.  
  373. <h2>Troubleshoot</h2>
  374.  
  375.  
  376.  
  377. <p>Looking at logfiles helps a lot &#8211; if you have access to the logfiles. Fortunately IoT Edge can expose data in the Prometheus exposition format for the edgeHub and edgeAgent. These endpoints are enabled by default for IoT Edge 1.0.10 (upgrade to this version if you haven&#8217;t) and can be enabled for 1.0.9. </p>
  378.  
  379.  
  380.  
  381. <p>The data can then be uploaded to Log Analytics for further analysis and to create alerts with a sample metrics-collector module.</p>
  382.  
  383.  
  384.  
  385. <ul><li><a rel="noreferrer noopener" href="https://github.com/Azure/iotedge/commits/master/doc/BuiltInMetrics.md" target="_blank">Built in Metrics (&gt;= 1.0.10)</a></li><li><a rel="noreferrer noopener" href="https://github.com/Azure/iotedge/blob/5971e5ed61f5c0320dfc9f9aa878831d3bc2570c/doc/BuiltInMetrics.md" target="_blank">Built in Metrics (1.0.9)</a></li><li><a rel="noreferrer noopener" href="https://hub.docker.com/r/azureiotedge/azureiotedge-metrics-collector-sample" data-type="URL" data-id="https://hub.docker.com/r/azureiotedge/azureiotedge-metrics-collector-sample" target="_blank">Metrics-Collector sample module</a></li></ul>
  386.  
  387.  
  388.  
  389. <p>For analyzation and to display the metrics, you can use a Workbook in Azure Monitor.</p>
  390.  
  391.  
  392.  
  393. <figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="216" src="https://www.hezser.de/blog/files/image-5-1024x216.png" alt="" class="wp-image-2833" srcset="https://www.hezser.de/blog/files/image-5-1024x216.png 1024w, https://www.hezser.de/blog/files/image-5-300x63.png 300w, https://www.hezser.de/blog/files/image-5-768x162.png 768w, https://www.hezser.de/blog/files/image-5.png 1120w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Azure Monitor Workbook with edgeHub log extract</figcaption></figure>
  394.  
  395.  
  396.  
  397. <p>In this particular case I could see that the available disk space was going down, down, down until the whole device did not respond anymore (no SSH access possible, no data sent to Azure).</p>
  398.  
  399.  
  400.  
  401. <h2>What to change?</h2>
  402.  
  403.  
  404.  
  405. <p>Adding more space to the disk was not an option. Other solutions needed to solve the issue. There are 2 options I looked at and adjusted to be a better fit for the usage scenario and resource limitation.</p>
  406.  
  407.  
  408.  
  409. <ol><li>The <strong>Time to live</strong> setting defines how long messages will be kept on the device: <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/azure/iot-edge/offline-capabilities#optional-offline-settings" target="_blank">Operate devices offline &#8211; Azure IoT Edge | Microsoft Docs</a> (which is set to 2h per default).</li><li>The not so obvious <strong>Rocks DB</strong> size configures the size of the logfiles: <a rel="noreferrer noopener" href="https://github.com/Azure/iotedge/issues/2431#issuecomment-582089419" target="_blank">https://github.com/Azure/iotedge/issues/2431#issuecomment-582089419</a></li></ol>
  410.  
  411.  
  412.  
  413. <p>After tweaking the settings, the following graph shows that now the device cleans up data before the disk runs full.</p>
  414.  
  415.  
  416.  
  417. <figure class="wp-block-image size-large"><img loading="lazy" width="954" height="227" src="https://www.hezser.de/blog/files/image-4.png" alt="" class="wp-image-2830" srcset="https://www.hezser.de/blog/files/image-4.png 954w, https://www.hezser.de/blog/files/image-4-300x71.png 300w, https://www.hezser.de/blog/files/image-4-768x183.png 768w" sizes="(max-width: 954px) 100vw, 954px" /></figure>
  418.  
  419.  
  420.  
  421. <p>I can not give you values for you particular setup. You&#8217;ll need to figure them out for your setup depending on the amount of messages going though the Edge device and hardware sizing. Here are some pointers to settings which you might want to investigate, if you hit a similar problem on your devices:</p>
  422.  
  423.  
  424.  
  425. <ul><li>Time-to-live: <a href="https://github.com/Azure/iotedge/blob/master/doc/Route_priority_and_TTL.md">iotedge/Route_priority_and_TTL.md at master · Azure/iotedge (github.com)</a></li><li>Set the used protocol (MQTT/AMQP/HTTP): <a href="https://docs.microsoft.com/en-us/azure/iot-edge/production-checklist#disable-unused-protocols">Prepare to deploy your solution in production &#8211; Azure IoT Edge | Microsoft Docs</a></li><li>Place limits on log sizes: <a href="https://docs.microsoft.com/en-us/azure/iot-edge/production-checklist#place-limits-on-log-size">Prepare to deploy your solution in production &#8211; Azure IoT Edge | Microsoft Docs</a></li><li>Alternate cleanup of message store: <a href="https://github.com/Azure/iotedge/pull/2893">Alternate cleanup processor for MessageStore by dylanbronson · Pull Request #2893 · Azure/iotedge (github.com)</a></li><li>Optimize for performance will allocate larger files upon usage. Disabling might help: <a href="https://github.com/Azure/iotedge/blob/master/doc/EnvironmentVariables.md">iotedge/EnvironmentVariables.md at master · Azure/iotedge (github.com)</a></li></ul>
  426.  
  427.  
  428.  
  429. <figure class="wp-block-image size-large"><img loading="lazy" width="794" height="160" src="https://www.hezser.de/blog/files/image-9.png" alt="" class="wp-image-2842" srcset="https://www.hezser.de/blog/files/image-9.png 794w, https://www.hezser.de/blog/files/image-9-300x60.png 300w, https://www.hezser.de/blog/files/image-9-768x155.png 768w" sizes="(max-width: 794px) 100vw, 794px" /><figcaption>RocksDB sizes</figcaption></figure>
  430.  
  431.  
  432.  
  433. <p>The above image shows setting for RocksDB (orange: 512MB, blue, 128MB, green 256MB). With the default setting the device is running out of disk space.</p>
  434.  
  435.  
  436.  
  437. <h2>What can I do to prevent the device crashing?</h2>
  438.  
  439.  
  440.  
  441. <p>Well, it depends <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> You can find a setting from the above that will prevent a full disk for a known scenario. But if you don&#8217;t know which modules with which setting is deployed?</p>
  442.  
  443.  
  444.  
  445. <p>In this case an alarm for low disk space is an option. It then needs to trigger a function that calls a method on the device to restart the edgeHub. This will clear the cache.</p>
  446. ]]></content:encoded>
  447. <wfw:commentRss>https://www.hezser.de/blog/2020/11/03/azure-iot-edge-on-constraint-devices/feed/</wfw:commentRss>
  448. <slash:comments>0</slash:comments>
  449. </item>
  450. <item>
  451. <title>Azure IoT Edge not starting</title>
  452. <link>https://www.hezser.de/blog/2020/07/13/azure-iot-edge-not-starting/</link>
  453. <comments>https://www.hezser.de/blog/2020/07/13/azure-iot-edge-not-starting/#respond</comments>
  454. <dc:creator><![CDATA[René Hézser]]></dc:creator>
  455. <pubDate>Mon, 13 Jul 2020 16:21:44 +0000</pubDate>
  456. <category><![CDATA[IoT Edge]]></category>
  457. <category><![CDATA[IoTEdge]]></category>
  458. <guid isPermaLink="false">https://www.hezser.de/blog/?p=2822</guid>
  459.  
  460. <description><![CDATA[Sometimes a permission denied is a permission denied 🙁 [INFO] - Starting Azure IoT Edge Security Daemon[INFO] - Version - 1.0.10~rc1[INFO] - Using config file: /etc/iotedge/config.yaml[INFO] - Configuring /var/lib/iotedge as the home directory.[INFO] - Configuring certificates…[INFO] - Transparent gateway certificates not found, operating in quick start mode…[INFO] - Finished configuring provisioning environment variables and certificates.[INFO] [&#8230;]]]></description>
  461. <content:encoded><![CDATA[
  462. <p>Sometimes a permission denied is a permission denied <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
  463.  
  464.  
  465.  
  466. <p><code>[INFO] - Starting Azure IoT Edge Security Daemon<br>[INFO] - Version - 1.0.10~rc1<br>[INFO] - Using config file: /etc/iotedge/config.yaml<br>[INFO] - Configuring /var/lib/iotedge as the home directory.<br>[INFO] - Configuring certificates…<br>[INFO] - Transparent gateway certificates not found, operating in quick start mode…<br>[INFO] - Finished configuring provisioning environment variables and certificates.<br>[INFO] - Initializing hsm…<br>[INFO] - Finished initializing hsm.<br>[INFO] - Provisioning edge device…<br>[INFO] - Starting provisioning edge device via manual mode using a device connection string…<br>[INFO] - Manually provisioning device "iotedgedevice" in hub "iothub.azure-devices.net"<br>[INFO] - Finished provisioning edge device.<br>[INFO] - Initializing the module runtime…<br>[INFO] - Initializing module runtime…<br>[INFO] - Using runtime network id azure-iot-edge<br>[WARN] - Could not initialize module runtime<br>[WARN] - caused by: Container runtime error<br>[WARN] - caused by: error trying to connect: Permission denied (os error 13)<br>[ERR!] - The daemon could not start up successfully: Could not initialize module runtime<br>[ERR!] - caused by: Could not initialize module runtime<br>[ERR!] - caused by: Container runtime error<br>[ERR!] - caused by: error trying to connect: Permission denied (os error 13)</code></p>
  467.  
  468.  
  469.  
  470. <p>This is the output I got via<code>journalctl -u iotedge -f</code> on a testinstallation. </p>
  471.  
  472.  
  473.  
  474. <p>For troubleshooting purpose I looked at the <a href="https://docs.microsoft.com/en-us/azure/iot-edge/troubleshoot">https://docs.microsoft.com/en-us/azure/iot-edge/troubleshoot</a> guide. But nothing solved my problem. Then I disabled http and mqtt support as of <a href="https://docs.microsoft.com/en-us/azure/iot-edge/production-checklist">https://docs.microsoft.com/en-us/azure/iot-edge/production-checklist</a>. Still not starting.</p>
  475.  
  476.  
  477.  
  478. <p>Finally I got it up and running by creating a docker group, adding iotedge to it and changed the group ownership of the <code>/var/run/docker.sock</code> file <code>sudo chown root:docker /var/run/docker.sock</code></p>
  479.  
  480.  
  481.  
  482. <p>This post is meant to be found via search engines if you (or me again) has the same startup problems.</p>
  483.  
  484.  
  485.  
  486. <p>My context: Ubuntu 20.04 with snap installed docker</p>
  487. ]]></content:encoded>
  488. <wfw:commentRss>https://www.hezser.de/blog/2020/07/13/azure-iot-edge-not-starting/feed/</wfw:commentRss>
  489. <slash:comments>0</slash:comments>
  490. </item>
  491. <item>
  492. <title>Properties for IoT Messages in Azure Stream Analytics</title>
  493. <link>https://www.hezser.de/blog/2020/05/13/properties-for-iot-messages-in-azure-stream-analytics/</link>
  494. <comments>https://www.hezser.de/blog/2020/05/13/properties-for-iot-messages-in-azure-stream-analytics/#respond</comments>
  495. <dc:creator><![CDATA[René Hézser]]></dc:creator>
  496. <pubDate>Wed, 13 May 2020 20:08:13 +0000</pubDate>
  497. <category><![CDATA[Azure]]></category>
  498. <category><![CDATA[IoT]]></category>
  499. <category><![CDATA[Stream Analytics]]></category>
  500. <category><![CDATA[StreamAnalytics]]></category>
  501. <guid isPermaLink="false">https://www.hezser.de/blog/?p=2801</guid>
  502.  
  503. <description><![CDATA[In this post I want to show how to use properties that are added to messages that IoT devices are sending to Azure IoT Hub in Stream Analytics. And while talking about properties, let&#8217;s even use message enrichment 🙂 Sample Message The green properties will be added by the Message enrichment feature of IoT Hub, [&#8230;]]]></description>
  504. <content:encoded><![CDATA[
  505. <p>In this post I want to show how to use properties that are added to messages that IoT devices are sending to Azure IoT Hub in Stream Analytics. And while talking about properties, let&#8217;s even use message enrichment <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
  506.  
  507.  
  508.  
  509. <figure class="wp-block-image size-large"><img loading="lazy" width="844" height="316" src="https://www.hezser.de/blog/files/StreamAnalyticsMessageRouting.png" alt="" class="wp-image-2803" srcset="https://www.hezser.de/blog/files/StreamAnalyticsMessageRouting.png 844w, https://www.hezser.de/blog/files/StreamAnalyticsMessageRouting-300x112.png 300w, https://www.hezser.de/blog/files/StreamAnalyticsMessageRouting-768x288.png 768w" sizes="(max-width: 844px) 100vw, 844px" /><figcaption>Stream Analytics Architecture</figcaption></figure>
  510.  
  511.  
  512.  
  513. <h2>Sample Message</h2>
  514.  
  515.  
  516.  
  517. <p>The green properties will be added by the <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-message-enrichments-overview" target="_blank">Message enrichment</a> feature of IoT Hub, as the data is not most likely not known on the IoT device or does not need to be transferred with each message.</p>
  518.  
  519.  
  520.  
  521. <pre class="wp-block-preformatted">{
  522.  "body": {
  523.    "messageId": 2300,
  524.    "temperature": 28,
  525.    "humidity": 66
  526.  },
  527.  "enqueuedTime": "2020-05-08T09:55:24.886Z",
  528.  "properties": {
  529.    "temperatureAlert": "false",
  530.    <span class="has-inline-color has-vivid-green-cyan-color">"CustomerName": "Microsoft Deutschland GmbH",
  531.    "CustomerId": "4711"</span>
  532.  }
  533. }</pre>
  534.  
  535.  
  536.  
  537. <h2>Sample IoT Device</h2>
  538.  
  539.  
  540.  
  541. <p>This message is sent by a sample C# client. I used this one: <a href="https://github.com/Azure-Samples/azure-iot-samples-csharp/tree/master/iot-hub/Samples/device/MessageSample">https://github.com/Azure-Samples/azure-iot-samples-csharp/tree/master/iot-hub/Samples/device/MessageSample</a></p>
  542.  
  543.  
  544.  
  545. <p>The code that sends the message with the alert property has been adjusted to this:</p>
  546.  
  547.  
  548.  
  549. <pre class="wp-block-code"><code>string dataBuffer = $"{{\"messageId\":{count},\"temperature\":{_temperature},\"humidity\":{_humidity}}}";
  550. using (var eventMessage = new Message(Encoding.UTF8.GetBytes(dataBuffer)))
  551. {
  552.    eventMessage.Properties.Add("temperatureAlert", (_temperature > TemperatureThreshold) ? "true" : "false");
  553. </code></pre>
  554.  
  555.  
  556.  
  557. <h2>Configure IoT Hub</h2>
  558.  
  559.  
  560.  
  561. <h3>Device Twin</h3>
  562.  
  563.  
  564.  
  565. <p>In most cases the IoT (Edge) device does not know which customer it is associated, as it does not need to know. For further processing of the data &#8211; or for device management &#8211; this information is relevant. Therefore we add this information to the <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-device-twins" target="_blank">device twin</a> in Azure IoT Hub.</p>
  566.  
  567.  
  568.  
  569. <pre class="wp-block-code"><code> "version": 3,
  570.  "tags": {
  571.    "customer": {
  572.      "id": "4711",
  573.      "name": "Microsoft Deutschland GmbH"
  574.    }
  575.  },
  576.  "properties": {
  577. </code></pre>
  578.  
  579.  
  580.  
  581. <p>The property names do not need to match the desired properties that will be added via message enrichment. You can choose a structure that fits best.</p>
  582.  
  583.  
  584.  
  585. <h3>Message Enrichment</h3>
  586.  
  587.  
  588.  
  589. <p>We want to add the customer number and id from the device twins to the message before it is being passed along to an endpoint.</p>
  590.  
  591.  
  592.  
  593. <figure class="wp-block-image size-large"><img loading="lazy" width="839" height="298" src="https://www.hezser.de/blog/files/EnrichMessage.png" alt="" class="wp-image-2807" srcset="https://www.hezser.de/blog/files/EnrichMessage.png 839w, https://www.hezser.de/blog/files/EnrichMessage-300x107.png 300w, https://www.hezser.de/blog/files/EnrichMessage-768x273.png 768w" sizes="(max-width: 839px) 100vw, 839px" /><figcaption>Message Enrichment settings in IoT Hub</figcaption></figure>
  594.  
  595.  
  596.  
  597. <p>As you can see the name of the property that is added does not need to match the name of the twin properties. Make sure you add the message enrichment to the right endpoint(s). You can decide to add different properties to messages that are routed to different endpoints.</p>
  598.  
  599.  
  600.  
  601. <h2>Azure Stream Analytics</h2>
  602.  
  603.  
  604.  
  605. <p>In the Stream Analytics job we use a SQL like query to filter the incoming message stream and route the messages to endpoints. The query will work fine as long as you use only the columns that are in the body of the messages (like &#8220;temperature&#8221; or &#8220;humidity&#8221; in this examle).</p>
  606.  
  607.  
  608.  
  609. <p>To be able to use the values in the properties, we need to use the <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/stream-analytics-query/getmetadatapropertyvalue" target="_blank">GetMetadataPropertyValue</a> function. Please take not of the sentence  on the docs page: <font color="red">This function cannot be tested on the Azure portal using sample data</font></p>
  610.  
  611.  
  612.  
  613. <h4>Query</h4>
  614.  
  615.  
  616.  
  617. <pre class="wp-block-code"><code>SELECT
  618.    GetMetadataPropertyValue(&#91;IoTHub-Messaging], '&#91;User].&#91;temperatureAlert]') AS temperaturealert,
  619.    GetMetadataPropertyValue(&#91;IoTHub-Messaging], '&#91;User].&#91;CustomerName]') AS customername,
  620.    GetMetadataPropertyValue(&#91;IoTHub-Messaging], '&#91;User].&#91;CustomerId]') AS customerid,
  621.    *</code></pre>
  622.  
  623.  
  624.  
  625. <p>The first three columns are our property and message enrichment columns while the other columns are all added as well.</p>
  626.  
  627.  
  628.  
  629. <h4>Output</h4>
  630.  
  631.  
  632.  
  633. <p>Let&#8217;s assume we want to add all message to a storage account where the customer id is part of the path.</p>
  634.  
  635.  
  636.  
  637. <figure class="wp-block-image size-large"><img loading="lazy" width="677" height="1024" src="https://www.hezser.de/blog/files/StreamAnalyticsOutput-677x1024.jpg" alt="" class="wp-image-2817" srcset="https://www.hezser.de/blog/files/StreamAnalyticsOutput-677x1024.jpg 677w, https://www.hezser.de/blog/files/StreamAnalyticsOutput-198x300.jpg 198w, https://www.hezser.de/blog/files/StreamAnalyticsOutput.jpg 688w" sizes="(max-width: 677px) 100vw, 677px" /><figcaption>Stream Analytics Blob storage output</figcaption></figure>
  638.  
  639.  
  640.  
  641. <p>This will work, as we added the customerid column in the query and it can be used for the path. Remember this is a demo and we only use the customerid as part of the path.</p>
  642.  
  643.  
  644.  
  645. <p>In the architecture diagram at the beginning of the post an Alert route is drawn. You can achieve this by adding a second query to the job which routes certain messages to that output.</p>
  646. ]]></content:encoded>
  647. <wfw:commentRss>https://www.hezser.de/blog/2020/05/13/properties-for-iot-messages-in-azure-stream-analytics/feed/</wfw:commentRss>
  648. <slash:comments>0</slash:comments>
  649. </item>
  650. <item>
  651. <title>IoT-Edge-HddMonitoring</title>
  652. <link>https://www.hezser.de/blog/2020/01/30/iot-edge-hddmonitoring/</link>
  653. <comments>https://www.hezser.de/blog/2020/01/30/iot-edge-hddmonitoring/#respond</comments>
  654. <dc:creator><![CDATA[René Hézser]]></dc:creator>
  655. <pubDate>Thu, 30 Jan 2020 13:09:10 +0000</pubDate>
  656. <category><![CDATA[Azure]]></category>
  657. <category><![CDATA[IoT]]></category>
  658. <category><![CDATA[IoT Edge]]></category>
  659. <guid isPermaLink="false">https://www.hezser.de/blog/?p=2797</guid>
  660.  
  661. <description><![CDATA[With Azure IoT Edge you can deploy modules (also known as Docker Containers) to a server. I&#8217;ve created a sample solution on GitHub that deploys a module which monitors the temperature of the harddisk that the server is running on. https://github.com/ReneHezser/IoT-Edge-HddMonitoring The repository can be a starting point for further customization.]]></description>
  662. <content:encoded><![CDATA[
  663. <p>With Azure IoT Edge you can deploy modules (also known as Docker Containers) to a server. I&#8217;ve created a sample solution on GitHub that deploys a module which monitors the temperature of the harddisk that the server is running on.</p>
  664.  
  665.  
  666.  
  667. <p><a href="https://github.com/ReneHezser/IoT-Edge-HddMonitoring">https://github.com/ReneHezser/IoT-Edge-HddMonitoring</a></p>
  668.  
  669.  
  670.  
  671. <p>The repository can be a starting point for further customization.</p>
  672. ]]></content:encoded>
  673. <wfw:commentRss>https://www.hezser.de/blog/2020/01/30/iot-edge-hddmonitoring/feed/</wfw:commentRss>
  674. <slash:comments>0</slash:comments>
  675. </item>
  676. <item>
  677. <title>VisionAI DevKit won&#8217;t deploy a module</title>
  678. <link>https://www.hezser.de/blog/2019/11/27/visionai-devkit-wont-deploy-a-module/</link>
  679. <comments>https://www.hezser.de/blog/2019/11/27/visionai-devkit-wont-deploy-a-module/#respond</comments>
  680. <dc:creator><![CDATA[René Hézser]]></dc:creator>
  681. <pubDate>Wed, 27 Nov 2019 12:34:03 +0000</pubDate>
  682. <category><![CDATA[Docker]]></category>
  683. <category><![CDATA[IoT Edge]]></category>
  684. <category><![CDATA[VisionAI DevKit]]></category>
  685. <guid isPermaLink="false">https://www.hezser.de/blog/?p=2792</guid>
  686.  
  687. <description><![CDATA[Today my VisionAI DevKit was not deploying a module. In the logs (sudo journalctl -u iotedge -f) I could see the deployment was received: Successfully pulled image machinelearndfd8df7d.azurecr.io/mobilenetimagenet:3Creating module VisionSampleImagenet…Could not create module VisionSampleImagenetcaused by: No such image: machinelearndfd8df7d.azurecr.io/mobilenetimagenet:3 Strange. During troubleshooting I started docker images and saw a lot of older images and versions. [&#8230;]]]></description>
  688. <content:encoded><![CDATA[
  689. <p>Today my VisionAI DevKit was not deploying a module. In the logs (<code>sudo journalctl -u iotedge -f</code>) I could see the deployment was received:</p>
  690.  
  691.  
  692.  
  693. <p><code>Successfully pulled image machinelearndfd8df7d.azurecr.io/mobilenetimagenet:3<br>Creating module VisionSampleImagenet…<br>Could not create module VisionSampleImagenet<br>caused by: No such image: machinelearndfd8df7d.azurecr.io/mobilenetimagenet:3</code></p>
  694.  
  695.  
  696.  
  697. <p>Strange. During troubleshooting I started docker images and saw a lot of older images and versions. After deleting a log of them with <code>docker image rm xyz</code> the deployment succeeded and the module started. <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
  698.  
  699.  
  700.  
  701. <p>Learning: Clean up the mess&#8230;</p>
  702. ]]></content:encoded>
  703. <wfw:commentRss>https://www.hezser.de/blog/2019/11/27/visionai-devkit-wont-deploy-a-module/feed/</wfw:commentRss>
  704. <slash:comments>0</slash:comments>
  705. </item>
  706. <item>
  707. <title>Configure Azure IoT Edge for downstream devices</title>
  708. <link>https://www.hezser.de/blog/2019/09/05/configure-azure-iot-edge-for-downstream-devices/</link>
  709. <comments>https://www.hezser.de/blog/2019/09/05/configure-azure-iot-edge-for-downstream-devices/#comments</comments>
  710. <dc:creator><![CDATA[René Hézser]]></dc:creator>
  711. <pubDate>Thu, 05 Sep 2019 14:58:28 +0000</pubDate>
  712. <category><![CDATA[Uncategorised]]></category>
  713. <category><![CDATA[Azure]]></category>
  714. <category><![CDATA[IoT]]></category>
  715. <guid isPermaLink="false">https://www.hezser.de/blog/?p=2781</guid>
  716.  
  717. <description><![CDATA[A lot of documentation and posts are available to setup an Azure IoT Edge to act as an IoT Hub for downstream devices. In order to get it up and running in a dev environment, I had to do some more research. My setup is a RaspberryPi 3 with Raspbian stretch and an Azure IoT [&#8230;]]]></description>
  718. <content:encoded><![CDATA[
  719. <p>A lot of documentation and posts are available to setup an Azure IoT Edge to act as an IoT Hub for downstream devices. In order to get it up and running in a dev environment, I had to do some more research.</p>
  720.  
  721.  
  722.  
  723. <p>My setup is a RaspberryPi 3 with Raspbian stretch and an <a href="https://aka.ms/iot-devkit">Azure IoT DevKit</a> which looks like this. And please remember the setup I used is for development only. I&#8217;ve used symmetric key authentication for the IoT Device. In a production scenario you would probably use certificate based authentication and no self signed certificates for the TLS encryption.</p>
  724.  
  725.  
  726.  
  727. <figure class="wp-block-image"><img loading="lazy" width="1024" height="303" src="https://www.hezser.de/blog/files/image-1-1024x303.png" alt="Transparent Gateway" class="wp-image-2782" srcset="https://www.hezser.de/blog/files/image-1-1024x303.png 1024w, https://www.hezser.de/blog/files/image-1-300x89.png 300w, https://www.hezser.de/blog/files/image-1-768x227.png 768w, https://www.hezser.de/blog/files/image-1.png 1747w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Source: https://docs.microsoft.com/en-us/azure/iot-edge/iot-edge-as-gateway</figcaption></figure>
  728.  
  729.  
  730.  
  731. <p>Some starting points for reading are:</p>
  732.  
  733.  
  734.  
  735. <ul><li><a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="http://How an IoT Edge device can be used as a gateway" target="_blank">https://docs.microsoft.com/en-us/azure/iot-edge/iot-edge-as-gateway</a></li><li><a rel="noreferrer noopener" aria-label="https://docs.microsoft.com/en-us/azure/iot-edge/how-to-authenticate-downstream-device (opens in a new tab)" href="https://docs.microsoft.com/en-us/azure/iot-edge/how-to-authenticate-downstream-device" target="_blank">https://docs.microsoft.com/en-us/azure/iot-edge/how-to-authenticate-downstream-device</a></li><li><a href="https://docs.microsoft.com/en-us/azure/iot-edge/troubleshoot" target="_blank" rel="noreferrer noopener" aria-label="https://docs.microsoft.com/en-us/azure/iot-edge/troubleshoot (opens in a new tab)">https://docs.microsoft.com/en-us/azure/iot-edge/troubleshoot</a></li></ul>
  736.  
  737.  
  738.  
  739. <h2>And here are my findings with the solutions that worked for my setup</h2>
  740.  
  741.  
  742.  
  743. <ol><li>The downstream IoT devices should be able to connect to port 443 on the Edge module. But that port was not open/listening.</li><li>How to verify the gateway certificate after the connection has been established?</li></ol>
  744.  
  745.  
  746.  
  747. <p>The connectionstring for connecting to the gateway instead of an IoT Hub you can add <strong>;GatewayHostName=hostname</strong> and the device should then go to the gateway. Take a note of the hostname and make sure it matches the name you specified when you were creating the certificates.</p>
  748.  
  749.  
  750.  
  751. <p>Looking at the serial output of the DevKit, I noticed it could not connect to the gateway. A quick analysis revealed that it does not accept connections on port 443. Hmm. Maybe a firewall on the Pi? As it turned out you have to tell the edge container to listen to 443 if you want to use it as a gateway.</p>
  752.  
  753.  
  754.  
  755. <figure class="wp-block-image"><img loading="lazy" width="1024" height="596" src="https://www.hezser.de/blog/files/image-2-1024x596.png" alt="" class="wp-image-2785" srcset="https://www.hezser.de/blog/files/image-2-1024x596.png 1024w, https://www.hezser.de/blog/files/image-2-300x175.png 300w, https://www.hezser.de/blog/files/image-2-768x447.png 768w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Port bindings for the Edge module</figcaption></figure>
  756.  
  757.  
  758.  
  759. <pre class="wp-block-preformatted">{
  760.    "HostConfig": {
  761.        "PortBindings": {
  762.            "8883/tcp": [{ "HostPort": "8883" }],
  763.            "443/tcp": [{ "HostPort": "443" }],
  764.            "5671/tcp": [{ "HostPort": "5671" }]
  765.        }
  766.    }
  767. }</pre>
  768.  
  769.  
  770.  
  771. <p>This will allow incoming connections not only for HTTPS. After the change was pushed to the Edge device, I could connect to it on port 443. Hurray.</p>
  772.  
  773.  
  774.  
  775. <p>The next challenge was to get the downstream device accept the certificate, that the gateway offered. In order to be able to verify the certificate, it has to trust the root certificate. This was, in my case, the file <strong>azure-iot-test-only.root.ca.cert.pem</strong>&nbsp;from the ~/certividates/certs directory. Open it with an editor, paste the content into the ino file and use the certificate.</p>
  776.  
  777.  
  778.  
  779. <pre class="wp-block-preformatted">// declare a constant with the content of
  780. //&nbsp;azure-iot-test-only.root.ca.cert.pem&nbsp;from&nbsp;~/certificates/certs
  781. static&nbsp;const&nbsp;char&nbsp;edgeCert&nbsp;[]&nbsp;=
  782. "-----BEGIN&nbsp;CERTIFICATE-----\r\n"
  783. ...
  784. "-----END&nbsp;CERTIFICATE-----";
  785.  
  786. // set trusted certs for the client
  787. DevKitMQTTClient_SetOption(OPTION_MINI_SOLUTION_NAME,&nbsp;"something");
  788. DevKitMQTTClient_SetOption("TrustedCerts",&nbsp;edgeCert);</pre>
  789.  
  790.  
  791.  
  792. <p>Now the IoT device should be able to connect to the gateway. Have fun with IoT <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
  793. ]]></content:encoded>
  794. <wfw:commentRss>https://www.hezser.de/blog/2019/09/05/configure-azure-iot-edge-for-downstream-devices/feed/</wfw:commentRss>
  795. <slash:comments>1</slash:comments>
  796. </item>
  797. </channel>
  798. </rss>
  799.  

If you would like to create a banner that links to this page (i.e. this validation result), do the following:

  1. Download the "valid RSS" banner.

  2. Upload the image to your own server. (This step is important. Please do not link directly to the image on this server.)

  3. Add this HTML to your page (change the image src attribute if necessary):

If you would like to create a text link instead, here is the URL you can use:

http://www.feedvalidator.org/check.cgi?url=http%3A//feeds2.feedburner.com/ReneHezser

Copyright © 2002-9 Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda