{"id":2569,"date":"2019-09-24T16:30:41","date_gmt":"2019-09-24T08:30:41","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/iotdev\/?p=2569"},"modified":"2019-09-24T16:30:41","modified_gmt":"2019-09-24T08:30:41","slug":"debug-azure-iot-edge-c-remote-linux-module-container-with-visual-studio-2019-version-16-3","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/iotdev\/debug-azure-iot-edge-c-remote-linux-module-container-with-visual-studio-2019-version-16-3\/","title":{"rendered":"Debug Azure IoT Edge C# Remote Linux Module Container with Visual Studio 2019 Version 16.3"},"content":{"rendered":"<p>With the <a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/dot-net-core-support-in-visual-studio-2019-version-16-3\/\">16.3 release of Visual Studio 2019<\/a>, it starts to support debugging C# in Linux docker containers. This new feature can help developers easily debug remote Azure IoT Edge C# Linux module container.<\/p>\n<p>Let\u2019s see how it works.<\/p>\n<h3><strong>Prerequisites<\/strong><\/h3>\n<h4>Setup Your Linux machine<\/h4>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/iot-edge\/how-to-install-iot-edge-linux\">Install and config Azure IoT Edge runtime<\/a> on your remote Linux machine.<\/li>\n<li><a href=\"https:\/\/linuxize.com\/post\/how-to-enable-ssh-on-ubuntu-18-04\/\">Enable SSH<\/a> on your remote Linux machine.<\/li>\n<li><a href=\"https:\/\/docs.docker.com\/install\/linux\/linux-postinstall\/#manage-docker-as-a-non-root-user\">Manage Docker as a non-root user<\/a>, so that you don\u2019t need to preface the docker command with <strong>sudo<\/strong>.<\/li>\n<\/ul>\n<h4>Setup Your Development Machine<\/h4>\n<ul>\n<li>OS: Windows 10<\/li>\n<li>Visual Studio 2019 with version of <strong>16.3.0 or later<\/strong>, including workloads <strong>\u201c.NET desktop development\u201d<\/strong> and <strong>\u201cAzure development workload\u201d<\/strong><\/li>\n<li>Download and install\u202f<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vsc-iot.vs16iotedgetools\">Azure IoT Edge extension for Visual Studio 2019<\/a><\/li>\n<li>Download and install <a href=\"https:\/\/hub.docker.com\/editions\/community\/docker-ce-desktop-windows\">Docker Desktop for Windows<\/a><\/li>\n<\/ul>\n<h3><strong>Debug C# Module Container Running in Remote Edge Device<\/strong><\/h3>\n<ol>\n<li>Open Visual Studio 2019. In the\u00a0<strong>Create a New Project<\/strong>\u00a0dialog, search \u201ciot\u201d, and select\u00a0<strong>Azure IoT Edge (Linux amd64)<\/strong>, click \u201cnext\u201d and enter a name for your project and specify the location, and then click\u00a0<strong>Create<\/strong>.<img decoding=\"async\" class=\"wp-image-2571\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image.png\" width=\"834\" height=\"567\" \/><img decoding=\"async\" class=\"wp-image-2572\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-1.png\" width=\"834\" height=\"579\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-1.png 1280w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-1-300x208.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-1-768x533.png 768w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-1-1024x710.png 1024w\" sizes=\"(max-width: 834px) 100vw, 834px\" \/><\/li>\n<li>In the <strong>Add Module<\/strong> wizard, select <strong>C# Module<\/strong>, and replace\u202f<strong>localhost:5000<\/strong>\u202fwith your own registry info, then click\u202f<strong>Add<\/strong>:<img decoding=\"async\" class=\"wp-image-2573\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-2.png\" width=\"835\" height=\"630\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-2.png 984w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-2-300x226.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-2-768x579.png 768w\" sizes=\"(max-width: 835px) 100vw, 835px\" \/><\/li>\n<li>Now there\u2019re two projects in the solution, the first one \u201c<strong>IotEdgeModule1<\/strong>\u201d is Azure IoT Edge module project, which is just simple .Net Core project. The other one RemoteEdgeContainerDebug is Azure IoT Edge deployment project.<img decoding=\"async\" width=\"439\" height=\"373\" class=\"wp-image-2574\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-3.png\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-3.png 439w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-3-300x255.png 300w\" sizes=\"(max-width: 439px) 100vw, 439px\" \/><\/li>\n<li>Click Edge project, and change <strong>Target Configuration<\/strong> to <strong><strong><strong>Debug\n<p><\/strong><\/strong><\/strong><img decoding=\"async\" width=\"518\" height=\"266\" class=\"wp-image-2575\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-4.png\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-4.png 518w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-4-300x154.png 300w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/li>\n<li>Click <strong>Show All Files<\/strong> icon as below, a <strong>.<\/strong><strong>env<\/strong> file should be displayed under Edge project, open the <strong>.<\/strong><strong>env<\/strong> file to input credential for your registry, this credential will be used by Azure IoT Edge runtime to pull module images after deployment.<img decoding=\"async\" width=\"895\" height=\"453\" class=\"wp-image-2576\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-5.png\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-5.png 895w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-5-300x152.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-5-768x389.png 768w\" sizes=\"(max-width: 895px) 100vw, 895px\" \/><\/li>\n<li>Since we\u2019re using a private container registry, use the following Docker command to sign in.\n<pre class=\"lang:default decode:true \">docker login -u &lt;ACR username&gt; -p &lt;ACR password&gt; &lt;ACR login server&gt;<\/pre>\n<\/li>\n<li>Right click on the Edge project and click <strong>Build and Push IoT Edge Modules<\/strong> to build, push the Docker image for the C# module. After push is done, open\u202f<strong>Cloud Explorer<\/strong>\u202fby clicking\u202f<strong>View<\/strong>\u202f-&gt;\u202f<strong>Cloud Explorer<\/strong>, expand your subscription and find the IoT Edge device corresponding to your remote Linux device, right click on the IoT Edge device to create a deployment for it, you need to select the deployment manifest file under the path below:\n<pre class=\"lang:default decode:true \">$AzureIoTEdgeAppSolutionDir\\$AzureIotEdgeAppX\\config\\deployment.amd64.debug.json\r\n<\/pre>\n<p><img decoding=\"async\" width=\"436\" height=\"536\" class=\"wp-image-2577\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-6.png\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-6.png 436w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-6-244x300.png 244w\" sizes=\"(max-width: 436px) 100vw, 436px\" \/><\/li>\n<li>Click <strong>Debug -&gt; Attach to Process<\/strong>, set <strong>Connection Type<\/strong> to <strong>Docker (Linux Container)<\/strong> and <strong><strong><strong>click Find\u2026<\/strong><\/strong><\/strong>&nbsp;\n<p><img decoding=\"async\" width=\"978\" height=\"807\" class=\"wp-image-2578\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-7.png\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-7.png 978w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-7-300x248.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-7-768x634.png 768w\" sizes=\"(max-width: 978px) 100vw, 978px\" \/><\/li>\n<li><span style=\"font-size: 1rem;\">Click <\/span><strong style=\"font-size: 1rem;\">Add\u2026<\/strong><span style=\"font-size: 1rem;\"> button <\/span>from <strong style=\"font-size: 1rem;\">Select Docker Container<\/strong><span style=\"font-size: 1rem;\"><span style=\"font-size: 1rem;\"><span style=\"font-size: 1rem;\"> dialog, and input your remote Linux machine\u2019s IP, username and password.<\/span><\/span><\/span>&nbsp;\n<p><img decoding=\"async\" width=\"560\" height=\"543\" class=\"wp-image-2579\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-8.png\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-8.png 560w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-8-300x291.png 300w\" sizes=\"(max-width: 560px) 100vw, 560px\" \/><\/li>\n<li>After successfully connecting to the SSH, then you can choose which container you want to Attach. In our scenario, we should select \u201cIoTEdgeModule1\u201d which is the C# module container.<img decoding=\"async\" width=\"547\" height=\"742\" class=\"wp-image-2580\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-9.png\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-9.png 547w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-9-221x300.png 221w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/>\u3001<\/li>\n<li>Select process <strong>dotnet <\/strong>to attach.<img decoding=\"async\" width=\"978\" height=\"807\" class=\"wp-image-2581\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-10.png\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-10.png 978w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-10-300x248.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-10-768x634.png 768w\" sizes=\"(max-width: 978px) 100vw, 978px\" \/><\/li>\n<li>If everything works fine, now you can debug your C# module in Visual Studio:<img decoding=\"async\" width=\"1137\" height=\"235\" class=\"wp-image-2582\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-11.png\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-11.png 1137w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-11-300x62.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-11-768x159.png 768w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/09\/word-image-11-1024x212.png 1024w\" sizes=\"(max-width: 1137px) 100vw, 1137px\" \/><\/li>\n<\/ol>\n<h3><strong>Summary<\/strong><\/h3>\n<p>With the new release of Visual Studio 2019, now you can easily debug Azure IoT Edge C# Linux module containers. You can download and try it with Visual Studio 16.3. \u00a0Additionally, please report any issues you encounter, any feature request you have or other questions to vsciet@microsoft.com.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the 16.3 release of Visual Studio 2019, it starts to support debugging C# in Linux docker containers. This new feature can help developers easily debug remote Azure IoT Edge C# Linux module container. Let\u2019s see how it works. Prerequisites Setup Your Linux machine Install and config Azure IoT Edge runtime on your remote Linux [&hellip;]<\/p>\n","protected":false},"author":1253,"featured_media":1836,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[478,288,290],"tags":[5,6,164,7,9,11,19,20,376],"class_list":["post-2569","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-iot-device","category-azure-iot-edge-development","category-azure-iot-hub","tag-azure","tag-azure-iot","tag-azure-iot-edge","tag-azure-iot-hub","tag-debug","tag-development-tools","tag-iot-development-tools","tag-iot-edge","tag-visual-studio"],"acf":[],"blog_post_summary":"<p>With the 16.3 release of Visual Studio 2019, it starts to support debugging C# in Linux docker containers. This new feature can help developers easily debug remote Azure IoT Edge C# Linux module container. Let\u2019s see how it works. Prerequisites Setup Your Linux machine Install and config Azure IoT Edge runtime on your remote Linux [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/posts\/2569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/users\/1253"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/comments?post=2569"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/posts\/2569\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/media\/1836"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/media?parent=2569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/categories?post=2569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/tags?post=2569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}