{"id":225664,"date":"2019-06-12T08:00:14","date_gmt":"2019-06-12T15:00:14","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=225664"},"modified":"2020-01-02T21:42:14","modified_gmt":"2020-01-03T05:42:14","slug":"azure-iot-tools-help-you-connect-to-azure-iot-hub-in-1-minute-in-visual-studio-code","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/azure-iot-tools-help-you-connect-to-azure-iot-hub-in-1-minute-in-visual-studio-code\/","title":{"rendered":"Azure IoT Tools help you connect to Azure IoT Hub in 1 minute in Visual Studio Code"},"content":{"rendered":"<p>When doing development for Azure IoT solutions, developers may want to test and debug their cloud solution with a real device. However, not every developer has a real device in their hand.\u00a0 With the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vsciot-vscode.azure-iot-tools\">Azure IoT Tools for Visual Studio Code<\/a>, you can easily use Visual Studio Code as a device simulator to quickly interact with Azure IoT Hub. Let\u2019s see how easy it is to send a D2C (device-to-cloud) message in Visual Studio Code! Say Hello to IoT Hub in Visual Studio Code in 1 minute!<\/p>\n<p><strong>Prerequisites<\/strong><\/p>\n<ol>\n<li>If you don\u2019t have an Azure subscription, create a\u00a0<a href=\"https:\/\/azure.microsoft.com\/free\/?WT.mc_id=A261C142F\">free account<\/a>\u00a0before you begin.<\/li>\n<li>Install <a href=\"https:\/\/code.visualstudio.com\/\">Visual Studio Code<\/a><\/li>\n<li>Install the\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vsciot-vscode.azure-iot-tools\">Azure IoT Tools<\/a> extension for Visual Studio Code<\/li>\n<\/ol>\n<p><strong>Create an IoT Hub<\/strong><\/p>\n<p>The first step is to\u00a0create an IoT Hub\u00a0in your subscription from Visual Studio Code.<\/p>\n<ol>\n<li>Click\u00a0<strong>\u2026 &gt; Create IoT Hub<\/strong>\u00a0at\u00a0<strong>AZURE IOT HUB<\/strong>\u00a0tab, or type\u00a0<strong>Azure IoT Hub: Create IoT Hub<\/strong>\u00a0in\u00a0Command Palette. (If you want to use an existing IoT Hub, click\u00a0<strong>\u2026 &gt; Select IoT Hub<\/strong>\u00a0at\u00a0<strong>AZURE IOT HUB <\/strong>tab)<\/li>\n<li>Choose your subscription, resource group, and the closest deploy location to you.<\/li>\n<li>For\u00a0Pricing and scale tier, select the\u00a0<strong>F1 \u2013 Free<\/strong>\u00a0tier if it\u2019s still available on your subscription.<\/li>\n<li>Enter the name of your IoT Hub.<\/li>\n<li>Wait a few minutes until the IoT Hub is created. you can see that your devices status become\u00a0<strong>No device in \u2026<\/strong>.<\/li>\n<\/ol>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225668\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/06\/create-hub.gif\" alt=\"\" width=\"940\" height=\"633\" \/><\/p>\n<p><strong>Register a device<\/strong><\/p>\n<p>A device must\u00a0be registered\u00a0with your IoT Hub before it can connect.<\/p>\n<ol>\n<li>Click\u00a0<strong>\u2026 &gt; Create Device<\/strong>\u00a0at\u00a0<strong>AZURE IOT HUB <\/strong>tab, or type\u00a0<strong>Azure IoT Hub: Create Device<\/strong>\u00a0in\u00a0Command Palette.<\/li>\n<li>Enter device ID and press\u00a0<strong>Enter<\/strong>.<\/li>\n<li>Wait a few seconds until the new device is created.<\/li>\n<\/ol>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225667\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/06\/create-device.gif\" alt=\"\" width=\"940\" height=\"633\" \/><\/p>\n<p><strong>Say Hello to IoT Hub (Send D2C message)<\/strong><\/p>\n<p>Right-click your device and select\u00a0<strong>Send D2C message to IoT Hub<\/strong>, then enter the message, results will be shown in\u00a0<strong>OUTPUT &gt; Azure IoT Hub <\/strong>view. Your \u2018Hello World\u2019 is sent to Azure IoT Hub!<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225669\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/06\/send-d2c.gif\" alt=\"\" width=\"940\" height=\"633\" \/><\/p>\n<p><strong>Monitor IoT Hub D2C message in Visual Studio Code<\/strong><\/p>\n<p>While you could send message to your IoT Hub, it is also possible to\u00a0monitor those messages\u00a0in Visual Studio Code.<\/p>\n<ul>\n<li>Right-click your device and select\u00a0<strong>Start Monitoring Built-in Event Endpoint<\/strong>.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225670\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/06\/start.png\" alt=\"\" width=\"387\" height=\"380\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/06\/start.png 387w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/06\/start-300x295.png 300w\" sizes=\"(max-width: 387px) 100vw, 387px\" \/><\/p>\n<ul>\n<li>The monitored\u00a0messages will be shown in\u00a0<strong>OUTPUT &gt; Azure IoT Hub <\/strong>view.<\/li>\n<li>To stop monitoring, right-click the\u00a0<strong>OUTPUT<\/strong>\u00a0view and select\u00a0<strong>Stop Monitoring Built-in Event Endpoint<\/strong>.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225671\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/06\/stop.png\" alt=\"\" width=\"806\" height=\"544\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/06\/stop.png 806w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/06\/stop-300x202.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/06\/stop-768x518.png 768w\" sizes=\"(max-width: 806px) 100vw, 806px\" \/><\/p>\n<p>Is that cool? You could send and receive messages for Azure IoT Hub very easily in Visual Studio Code. Is that all? Not yet! Actually, you could use\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vsciot-vscode.azure-iot-tools\">Azure IoT Tools extension<\/a>\u00a0to do lots of things when you develop with Azure IoT Hub! Checkout our\u00a0<a href=\"https:\/\/github.com\/microsoft\/vscode-azure-iot-tools\/wiki\">Wiki Page<\/a>\u00a0to see the full list of features and tutorials. You could also use Azure IoT Tools to easily <a href=\"https:\/\/devblogs.microsoft.com\/iotdev\/azure-iot-toolkit-1-2-0-quickly-build-your-azure-iot-application-in-vs-code-with-node-js-python-or-rest-api\/\">call Azure IoT Hub REST APIs<\/a> or <a href=\"https:\/\/devblogs.microsoft.com\/iotdev\/azure-iot-toolkit-supports-c-go-java-node-js-php-python-and-ruby-to-develop-azure-iot-application-in-vs-code\/\">generate Azure IoT application with different languages such as C#, Java, Node.js, PHP, Python<\/a>. For more IoT tooling announcements and tutorials, please check out <a href=\"https:\/\/devblogs.microsoft.com\/iotdev\/\">our IoT Developer Blog<\/a>. Azure IoT Tools make your Azure IoT development easier.<\/p>\n<p>Useful Resources:<\/p>\n<ul>\n<li><a href=\"https:\/\/channel9.msdn.com\/Shows\/Internet-of-Things-Show\/Azure-IoT-Toolkit-extension-for-Visual-Studio-Code\">Channel 9 video: Walkthrough of Azure IoT Hub extension<\/a><\/li>\n<li><a href=\"https:\/\/channel9.msdn.com\/Shows\/Internet-of-Things-Show\/Whats-new-in-the-IoT-Toolkit-extension-for-VS-Code\">Channel 9 video: What&#8217;s new in the IoT Hub extension for Visual Studio Code<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/iot-hub\/iot-hub-vscode-iot-toolkit-cloud-device-messaging\">Send and receive messages between your device and IoT Hub<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/iot-hub\/iot-hub-device-management-iot-toolkit\">Azure IoT Hub device management<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>When doing development for Azure IoT solutions, developers may want to test and debug their cloud solution with a real device. However, not every developer has a real device in their hand.\u00a0 With the Azure IoT Tools for Visual Studio Code, you can easily use Visual Studio Code as a device simulator to quickly interact with Azure IoT Hub. <\/p>\n","protected":false},"author":672,"featured_media":225721,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[561,155],"tags":[242,382,280],"class_list":["post-225664","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source","category-visual-studio","tag-azure","tag-iot","tag-visual-studio-code"],"acf":[],"blog_post_summary":"<p>When doing development for Azure IoT solutions, developers may want to test and debug their cloud solution with a real device. However, not every developer has a real device in their hand.\u00a0 With the Azure IoT Tools for Visual Studio Code, you can easily use Visual Studio Code as a device simulator to quickly interact with Azure IoT Hub. <\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/225664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/672"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=225664"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/225664\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/225721"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=225664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=225664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=225664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}