{"id":2319,"date":"2019-03-14T09:08:03","date_gmt":"2019-03-14T01:08:03","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/iotdev\/?p=2319"},"modified":"2019-05-23T14:32:15","modified_gmt":"2019-05-23T06:32:15","slug":"easily-develop-and-debug-azure-iot-edge-c-modules-with-azure-iot-edge-tools-preview-0-3-1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/iotdev\/easily-develop-and-debug-azure-iot-edge-c-modules-with-azure-iot-edge-tools-preview-0-3-1\/","title":{"rendered":"Easily develop and debug Azure IoT Edge C modules with Azure IoT Edge Tools (Preview) 0.3.1"},"content":{"rendered":"<p><strong>NOTE<\/strong>: Although this post is using Visual Studio 2017 as example, you could also successfully complete this tutorial with Visual Studio 2019 and <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vsc-iot.vs16iotedgetools\">Azure IoT Edge Tools (Preview) for VS 2019<\/a>.<\/p>\n<p>With 0.3.1 release of Azure IoT Edge Tools (Preview), you can use Visual Studio 2017 to develop and debug C modules for Azure IoT Edge.<\/p>\n<h4>Prerequisites<\/h4>\n<ul>\n<li>OS: Windows 10 with 1809 update<\/li>\n<li>Visual Studio 2017 with update 7 or later, including workloads &#8220;Windows desktop development with C++&#8221; and &#8220;Azure development workload&#8221;; you should include &#8220;.NET desktop development&#8221; as well if you plan to develop C# modules<\/li>\n<li>Download and install\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vsc-iot.vsiotedgetools\" data-linktype=\"external\">Azure IoT Edge extension (Preview) for Visual Studio<\/a><\/li>\n<li>You may either use container engine Moby or Docker Desktop for Windows\n<ul>\n<li>To use container engine Moby, first follow <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/iot-edge\/quickstart\">IoT Edge quickstart<\/a>\u00a0until running <strong>iotedge list <\/strong>in the doc, then search and click\u00a0<strong>edit system environment variables<\/strong> in Control Panel, then add environment variable <strong>DOCKER_HOST=npipe:\/\/\/\/.\/pipe\/iotedge_moby_engine\n<img decoding=\"async\" class=\"alignnone wp-image-2342\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/set-docker-host.png\" alt=\"\" width=\"748\" height=\"441\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/set-docker-host.png 1302w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/set-docker-host-300x177.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/set-docker-host-768x453.png 768w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/set-docker-host-1024x604.png 1024w\" sizes=\"(max-width: 748px) 100vw, 748px\" \/>\n<\/strong>Please note you should restart Visual Studio after editing environment variables to make the change taking effect.<\/li>\n<li>To use Docker Desktop for Windows, download and install <a href=\"https:\/\/hub.docker.com\/editions\/community\/docker-ce-desktop-windows\">Docker Desktop for Windows<\/a>.<\/li>\n<\/ul>\n<\/li>\n<li>Set up your local development environment to debug, run, and test your IoT Edge solution by installing the\u00a0<a href=\"https:\/\/pypi.org\/project\/iotedgehubdev\/\" data-linktype=\"external\">Azure IoT EdgeHub Dev Tool<\/a>. Install\u00a0<a href=\"https:\/\/www.python.org\/\" data-linktype=\"external\">Python (2.7\/3.6) and Pip<\/a>\u00a0and then install the\u00a0<strong>iotedgehubdev<\/strong>\u00a0package by running the following command in your terminal. Make sure your Azure IoT EdgeHub Dev Tool version is greater than 0.7.0.<\/li>\n<li>To test your module on a device, you&#8217;ll need an active IoT hub with at least one IoT Edge device. To use your computer as an IoT Edge device, follow the steps in the quickstart for\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/iot-edge\/quickstart-linux\" data-linktype=\"relative-path\">Linux<\/a>\u00a0or\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/iot-edge\/quickstart\" data-linktype=\"relative-path\">Windows<\/a>.<\/li>\n<li>Install azure-iot-sdk-c for windows-x64 through vcpkg\n<pre class=\"lang:default decode:true\">git clone https:\/\/github.com\/Microsoft\/vcpkg\r\ncd vcpkg\r\n.\\bootstrap-vcpkg.bat\r\n.\\vcpkg install azure-iot-sdk-c:x64-windows\r\n.\\vcpkg --triplet x64-windows integrate install\r\n<\/pre>\n<\/li>\n<\/ul>\n<h4>Switch to Windows Containers<\/h4>\n<p>This doc will use windows containers to demonstrate how to build, debug and deploy C modules using Windows IoT Edge project (which ending with Windows.Amd64 by default).<\/p>\n<ul>\n<li>If you&#8217;re using container engine Moby, please skip to next section <strong>Create Azure IoT Edge project<\/strong><\/li>\n<li>If you&#8217;re using Docker desktop for Windows, you need to switch to Windows containers.<\/li>\n<\/ul>\n<p><strong>Note<\/strong>: If you plan to build and debug Linux IoT Edge project (which ending with Linux.Amd64 by default), you need use Docker desktop and switch to Linux containers. Please make sure you have stopped edge related containers, e.g. edgeHubDev, edgeAgent before switching to different docker engine.<\/p>\n<h4>Create Azure IoT Edge project<\/h4>\n<p>The Azure IoT Edge project template allows you to create IoT Edge project for different platforms, currently supporting linux amd64 and windows amd64, each IoT Edge project could reference one or more IoT Edge modules.<\/p>\n<ol>\n<li>Run Visual Studio as <strong>administrator<\/strong>, select\u00a0<strong>New<\/strong>\u00a0&gt;\u00a0<strong>Project<\/strong>\u00a0from the\u00a0<strong>File<\/strong>\u00a0menu.<\/li>\n<li>In the\u00a0<strong>New Project<\/strong>\u00a0dialog, select\u00a0<strong>Installed &gt; Azure IoT<\/strong>, select\u00a0<strong>Azure IoT Edge<\/strong>, enter a name for your project and specify the location, and then select\u00a0<strong>OK<\/strong>. The default project name is\u00a0<strong>AzureIotEdgeApp1<\/strong>.\n<img decoding=\"async\" class=\"alignnone wp-image-2328\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/NewIoTEdgeProject.png\" alt=\"\" width=\"614\" height=\"287\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/NewIoTEdgeProject.png 1290w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/NewIoTEdgeProject-300x140.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/NewIoTEdgeProject-768x358.png 768w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/NewIoTEdgeProject-1024x478.png 1024w\" sizes=\"(max-width: 614px) 100vw, 614px\" \/><\/li>\n<li>In the project wizard, select both <strong>Linux Amd64<\/strong> and <strong>Windows Amd64<\/strong> for <strong>Application Platform<\/strong>, then select <strong>C Module<\/strong>, replace <strong>localhost:5000<\/strong> with your own registry info if necessary, then click <strong>OK<\/strong>.\n<img decoding=\"async\" class=\"alignnone wp-image-2327\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/NewIoTEdgeModule.png\" alt=\"\" width=\"615\" height=\"557\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/NewIoTEdgeModule.png 1277w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/NewIoTEdgeModule-300x272.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/NewIoTEdgeModule-768x696.png 768w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/NewIoTEdgeModule-1024x928.png 1024w\" sizes=\"(max-width: 615px) 100vw, 615px\" \/><\/li>\n<li>Now you have two IoT Edge projects, one is <strong>AzureIotEdgeApp.Linux.Amd64<\/strong> targeting to linux amd64, the other is <strong>AzureIotEdgeApp1.Windows.Amd64<\/strong> targeting to Windows amd64; you also have one IoT Edge module project <strong>IotEdgeModule1<\/strong> which is referenced by both IoT Edge projects<\/li>\n<\/ol>\n<h4>Develop your module<\/h4>\n<p>The default C module code that comes with the solution is located at\u00a0<strong>IotEdgeModule1 &gt; main.c<\/strong>. The module and the deployment.template.json file which is in IoT Edge project are set up so that you can build the IoT Edge project, push it to your container registry, and deploy it to a device to start testing without touching any code. The module is built to take input from a source (in this case, the\u00a0<strong>tempSensor\u00a0<\/strong>module that simulates data) and pipe it to Azure IoT Hub.<\/p>\n<h4>Initialize iotedgehubdev with IoT Edge device connection string<\/h4>\n<ol>\n<li>Copy the connection string of any IoT Edge device from\u00a0<strong>Primary Connection String<\/strong>\u00a0in the Visual Studio Cloud Explorer. Be sure not to copy the connection string of a non-Edge device, as the icon of an IoT Edge device is different from the icon of a non-Edge device.\n<img decoding=\"async\" class=\"alignnone size-full wp-image-2330\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/copy-edge-conn-string.png\" alt=\"\" width=\"261\" height=\"362\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/copy-edge-conn-string.png 261w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/copy-edge-conn-string-216x300.png 216w\" sizes=\"(max-width: 261px) 100vw, 261px\" \/><\/li>\n<li>Right-click on any IoT Edge project and then click\u00a0<strong>Set Edge Device Connection String<\/strong>\u00a0to open the Azure IoT Edge setup window.\n<img decoding=\"async\" class=\"alignnone size-full wp-image-2331\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/set-edge-conn-string.png\" alt=\"\" width=\"554\" height=\"484\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/set-edge-conn-string.png 554w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/set-edge-conn-string-300x262.png 300w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><\/li>\n<li>Enter the connection string from the first step and then select\u00a0<strong>OK<\/strong>.<\/li>\n<\/ol>\n<p>NOTE:\u00a0You need to follow above steps for initializing iotedgehubdev only once on your development computer as the results are automatically applied to all subsequent Azure IoT Edge solutions. This procedure can be followed again if you need to change to a different connection string.<\/p>\n<h4>Build and debug single C module<\/h4>\n<p>Typically, you&#8217;ll want to test and debug each module before running it within an entire solution with multiple modules.<\/p>\n<ol>\n<li>Right-click\u00a0<strong>IoTEdgeModule1<\/strong>\u00a0and select\u00a0<strong>Set as StartUp Project<\/strong>\u00a0from the context menu.<\/li>\n<li>Press\u00a0<strong>F5<\/strong>\u00a0or click the button below to run the module; it may take 10\u201320 seconds the first time you do so.\n<img decoding=\"async\" class=\"alignnone wp-image-2323\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeModule-1.png\" alt=\"\" width=\"750\" height=\"239\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeModule-1.png 2117w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeModule-1-300x96.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeModule-1-768x245.png 768w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeModule-1-1024x326.png 1024w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/li>\n<li>You could see an executable app start if the module has been initialized successfully.\n<img decoding=\"async\" class=\"alignnone size-full wp-image-2332\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/single-module-start.png\" alt=\"\" width=\"624\" height=\"79\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/single-module-start.png 624w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/single-module-start-300x38.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/li>\n<li>Set a breakpoint in the function\u00a0InputQueue1Callback in main.c<\/li>\n<li>Open <strong>Output<\/strong> windows in Visual Studio and switch to \u201c<strong>IoT Hub<\/strong>\u201d, please copy whole line starting with curl as highlighted below, and run it in <strong>Git Bash<\/strong> or <strong>WSL Bash<\/strong>, then the breakpoint will be hit.\n<img decoding=\"async\" class=\"alignnone wp-image-2324\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeModule-2.png\" alt=\"\" width=\"764\" height=\"266\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeModule-2.png 2457w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeModule-2-300x104.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeModule-2-768x267.png 768w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeModule-2-1024x356.png 1024w\" sizes=\"(max-width: 764px) 100vw, 764px\" \/>\n<img decoding=\"async\" class=\"alignnone wp-image-2326\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeProject-2.png\" alt=\"\" width=\"764\" height=\"301\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeProject-2.png 1149w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeProject-2-300x118.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeProject-2-768x302.png 768w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/DebugEdgeProject-2-1024x403.png 1024w\" sizes=\"(max-width: 764px) 100vw, 764px\" \/><\/li>\n<\/ol>\n<h4>Build and debug IoT Edge project with multiple modules<\/h4>\n<p>After you&#8217;re done developing a single module, you might want to run and debug an IoT Edge project with multiple modules.<\/p>\n<ol>\n<li>There&#8217;re two ways to add a new IoT Edge module to an existing IoT Edge project. The\u00a0<span style=\"font-size: 1rem;\">first way is to right click on IoT Edge project to open context menu, then select <\/span><strong style=\"font-size: 1rem;\">Add &gt; New IoT Edge Module<\/strong><span style=\"font-size: 1rem;\">; the second way is to right click on <\/span><b style=\"font-size: 1rem;\">Modules\u00a0<\/b><span style=\"font-size: 1rem;\">node of IoT Edge project, then select\u00a0<\/span><strong style=\"font-size: 1rem;\">Add &gt; New IoT Edge Module<\/strong><span style=\"font-size: 1rem;\">.\n<\/span><img decoding=\"async\" class=\"alignnone wp-image-2322\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/AddIoTEdgeModuleMenu.png\" alt=\"\" width=\"613\" height=\"494\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/AddIoTEdgeModuleMenu.png 604w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/AddIoTEdgeModuleMenu-300x242.png 300w\" sizes=\"(max-width: 613px) 100vw, 613px\" \/>\nIn the popup window, you may select the module you want to add, replace <strong style=\"font-size: 1rem;\">localhost:5000<\/strong><span style=\"font-size: 1rem;\"> with your registry info if necessary, then click <\/span><strong style=\"font-size: 1rem;\">OK<\/strong><span style=\"font-size: 1rem;\">.\n<img decoding=\"async\" class=\"alignnone wp-image-2333\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/AddIoTEdgeModule-1.png\" alt=\"\" width=\"609\" height=\"553\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/AddIoTEdgeModule-1.png 734w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/AddIoTEdgeModule-1-300x273.png 300w\" sizes=\"(max-width: 609px) 100vw, 609px\" \/><\/span><\/li>\n<li>Open the file\u00a0<code>deployment.template.json<\/code>\u00a0under IoT Edge project <strong>AzureIotEdgeApp1.Windows.Amd64<\/strong>, and you&#8217;ll see\u00a0<strong>IotEdgeModule2<\/strong>\u00a0has been added in the\u00a0<strong>modules<\/strong>\u00a0section. Replace the\u00a0<strong>routes<\/strong>\u00a0section with the following. If you have customized your module names, make sure you update these names to match.\n<pre class=\"lang:default decode:true\">        \"routes\": {\r\n          \"IotEdgeModule1ToIoTHub\": \"FROM \/messages\/modules\/IotEdgeModule1\/outputs\/* INTO $upstream\",\r\n          \"sensorToIotEdgeModule1\": \"FROM \/messages\/modules\/tempSensor\/outputs\/temperatureOutput INTO BrokeredEndpoint(\\\"\/modules\/IotEdgeModule1\/inputs\/input1\\\")\",\r\n          \"IotEdgeModule2ToIoTHub\": \"FROM \/messages\/modules\/IotEdgeModule2\/outputs\/* INTO $upstream\",\r\n          \"sensorToIotEdgeModule2\": \"FROM \/messages\/modules\/tempSensor\/outputs\/temperatureOutput INTO BrokeredEndpoint(\\\"\/modules\/IotEdgeModule2\/inputs\/input1\\\")\",\r\n        },<\/pre>\n<\/li>\n<li>Right-click <strong>AzureIotEdgeApp1.Windows.Amd64<\/strong> and select\u00a0<strong>Set as StartUp Project<\/strong>\u00a0from the context menu.<\/li>\n<li>Create your breakpoints and then press\u00a0<strong>F5<\/strong>\u00a0to run and debug multiple modules simultaneously. You should see multiple executable app windows, which each window representing a different C module.\n<img decoding=\"async\" class=\"alignnone wp-image-2336\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/multi-modules-run.png\" alt=\"\" width=\"711\" height=\"132\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/multi-modules-run.png 1218w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/multi-modules-run-300x56.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/multi-modules-run-768x143.png 768w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/multi-modules-run-1024x190.png 1024w\" sizes=\"(max-width: 711px) 100vw, 711px\" \/><\/li>\n<\/ol>\n<h4>Build and Push images<\/h4>\n<ol>\n<li>Right click on <strong>AzureIotEdgeApp1.Windows.Amd64<\/strong> and click <strong>Properties<\/strong>, select either Debug or Release as\u00a0the configuration to build for your module images.\nWhen choosing <strong>Release<\/strong>, Visual Studio uses <code>Dockerfile.windows-amd64<\/code>\u00a0to build Docker images; when choosing\u00a0<strong>Debug<\/strong>, Visual Studio first search\u00a0<code>Dockerfile.windows-amd64.<strong>debug<\/strong><\/code>\u00a0to build Docker images, it will use\u00a0<code>Dockerfile.windows-amd64<\/code>\u00a0instead if <code>Dockerfile.windows-amd64.<strong>debug<\/strong><\/code>\u00a0doesn&#8217;t exist.\n<img decoding=\"async\" class=\"alignnone wp-image-2335\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/select-project-properties.png\" alt=\"\" width=\"700\" height=\"484\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/select-project-properties.png 1048w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/select-project-properties-300x208.png 300w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/select-project-properties-768x531.png 768w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/select-project-properties-1024x708.png 1024w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/li>\n<li>If you&#8217;re using a private registry like Azure Container Registry, use the following Docker command to sign in to it. Currently local registry doesn&#8217;t support Windows container yet.\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>If you&#8217;re using a private registry like Azure Container Registry, you need to add your registry login information to the runtime settings found in the file\u00a0<code>deployment.template.json<\/code>. Replace the placeholders with your actual ACR admin username, password, and registry name.\n<pre class=\"lang:default decode:true\">\"settings\": {\r\n        \"minDockerVersion\": \"v1.25\",\r\n        \"loggingOptions\": \"\",\r\n        \"registryCredentials\": {\r\n          \"registry1\": {\r\n            \"username\": \"&lt;username&gt;\",\r\n            \"password\": \"&lt;password&gt;\",\r\n            \"address\": \"&lt;registry name&gt;.azurecr.io\"\r\n          }\r\n        }\r\n      }<\/pre>\n<\/li>\n<li>\u00a0Right-click <strong>AzureIotEdgeApp1.Windows.Amd64\u00a0<\/strong>and select\u00a0<strong>Build and Push IoT Edge Modules\u00a0<\/strong>to build and push the Docker image for each module.\n<img decoding=\"async\" class=\"alignnone size-full wp-image-2334\" src=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/build-push-images.png\" alt=\"\" width=\"546\" height=\"434\" srcset=\"https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/build-push-images.png 546w, https:\/\/devblogs.microsoft.com\/iotdev\/wp-content\/uploads\/sites\/24\/2019\/03\/build-push-images-300x238.png 300w\" sizes=\"(max-width: 546px) 100vw, 546px\" \/><\/li>\n<\/ol>\n<h4>Deploy the solution<\/h4>\n<p>You can also deploy modules using the Cloud Explorer for Visual Studio. You already have a deployment manifest prepared for your scenario, the\u00a0<code>deployment.json<\/code>\u00a0file and all you need to do is select a device to receive the deployment.<\/p>\n<ol>\n<li>Open\u00a0<strong>Cloud Explorer<\/strong>\u00a0by clicking\u00a0<strong>View<\/strong>\u00a0&gt;\u00a0<strong>Cloud Explorer<\/strong>. Make sure you&#8217;ve logged in to Visual Studio 2017.<\/li>\n<li>In\u00a0<strong>Cloud Explorer<\/strong>, expand your subscription, find your Azure IoT Hub and the Azure IoT Edge device you want to deploy.<\/li>\n<li>Right-click on the IoT Edge device to create a deployment for it, you need to select the deployment manifest file under the\u00a0<code>$AzureIoTEdgeAppSolutionDir\\$AzureIotEdgeApp.Windows.Amd64\\config\\deployment.(amd64|amd64.debug|windows-amd64).json<\/code><\/li>\n<li>Click the refresh button to see the new modules running along with the\u00a0<strong>TempSensor<\/strong>\u00a0module and\u00a0<strong>$edgeAgent<\/strong>\u00a0and\u00a0<strong>$edgeHub<\/strong><\/li>\n<\/ol>\n<h4>View generated data<\/h4>\n<ol>\n<li>To monitor the D2C message for a specific device, select the device in the list and then click\u00a0<strong>Start Monitoring D2C Messages<\/strong>\u00a0in the\u00a0<strong>Action<\/strong>\u00a0window.<\/li>\n<li>To stop monitoring data, select the device in the list and then select\u00a0<strong>Stop Monitoring D2C Messages<\/strong>\u00a0in the\u00a0<strong>Action<\/strong>\u00a0window.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NOTE: Although this post is using Visual Studio 2017 as example, you could also successfully complete this tutorial with Visual Studio 2019 and Azure IoT Edge Tools (Preview) for VS 2019. With 0.3.1 release of Azure IoT Edge Tools (Preview), you can use Visual Studio 2017 to develop and debug C modules for Azure IoT [&hellip;]<\/p>\n","protected":false},"author":529,"featured_media":1836,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[288],"tags":[164,376,536],"class_list":["post-2319","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-iot-edge-development","tag-azure-iot-edge","tag-visual-studio","tag-visual-studio-2017"],"acf":[],"blog_post_summary":"<p>NOTE: Although this post is using Visual Studio 2017 as example, you could also successfully complete this tutorial with Visual Studio 2019 and Azure IoT Edge Tools (Preview) for VS 2019. With 0.3.1 release of Azure IoT Edge Tools (Preview), you can use Visual Studio 2017 to develop and debug C modules for Azure IoT [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/posts\/2319","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\/529"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/comments?post=2319"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/posts\/2319\/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=2319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/categories?post=2319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/tags?post=2319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}