{"id":2340,"date":"2019-03-15T15:49:22","date_gmt":"2019-03-15T07:49:22","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/iotdev\/?p=2340"},"modified":"2019-03-15T15:49:22","modified_gmt":"2019-03-15T07:49:22","slug":"read-azure-iot-hub-device-to-cloud-messages-from-the-built-in-and-custom-endpoints","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/iotdev\/read-azure-iot-hub-device-to-cloud-messages-from-the-built-in-and-custom-endpoints\/","title":{"rendered":"Read Azure IoT Hub device-to-cloud messages from the built-in and custom endpoints"},"content":{"rendered":"<p>IoT Hub\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/iot-hub\/iot-hub-devguide-routing-query-syntax\" data-linktype=\"relative-path\">Message Routing<\/a>\u00a0enables users to route device-to-cloud messages to service-facing endpoints.\u00a0An IoT hub has a default\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/iot-hub\/iot-hub-devguide-messages-read-builtin\" data-linktype=\"relative-path\">built-in endpoint<\/a>. You can create custom endpoints to route messages to by linking other services in your subscription to the hub. IoT Hub currently supports Azure Storage containers, Event Hubs, Service Bus queues, and Service Bus topics as custom endpoints. During development and operation, developers would want to monitor the\u00a0device-to-cloud messages to see whether the Azure IoT application is working well. In this article, we will go through how to read device-to-cloud messages from the built-in and custom endpoints.<\/p>\n<h4>Reading from Built-in-endpoint<\/h4>\n<p>By default, messages are routed to the built-in service-facing endpoint (<strong>messages\/events<\/strong>) that is compatible with\u00a0<a href=\"https:\/\/azure.microsoft.com\/documentation\/services\/event-hubs\/\" data-linktype=\"external\">Event Hubs<\/a>. This endpoint is currently only exposed using the\u00a0<a href=\"https:\/\/www.amqp.org\/\" data-linktype=\"external\">AMQP<\/a>\u00a0protocol on port 5671.\u00a0With the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vsciot-vscode.azure-iot-toolkit\">Azure IoT Hub Toolkit<\/a>\u00a0Visual Studio Code, you could easily <a href=\"https:\/\/github.com\/Microsoft\/vscode-azure-iot-toolkit\/wiki\/Monitor-IoT-Hub-D2C-Message\">read device-to-cloud messages from the built-in endpoint<\/a>. If you are using Visual Studio, you could also use <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-azuretools.CloudExplorerForVS\">Cloud Explorer<\/a> to <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/iot-hub\/iot-hub-visual-studio-cloud-device-messaging\">monitor device-to-cloud messages<\/a>.<\/p>\n<h4>Reading from Azure Storage containers<\/h4>\n<p>IoT Hub supports writing data to Azure Blob Storage in the\u00a0<a href=\"https:\/\/avro.apache.org\/\" data-linktype=\"external\">Apache Avro<\/a>\u00a0as well as JSON format.\u00a0To read the data in\u00a0Azure Storage containers, the easiest way is to use\u00a0<a href=\"https:\/\/azure.microsoft.com\/en-us\/features\/storage-explorer\/\">Azure Storage Explorer<\/a>. You could also\u00a0use the\u00a0<a class=\"\" href=\"https:\/\/docs.microsoft.com\/rest\/api\/storageservices\/list-blobs\" data-linktype=\"external\">List Blobs API<\/a>\u00a0to enumerate the list of blobs.<\/p>\n<h4>Reading from Event Hubs<\/h4>\n<p>Apart from the built-in-Event Hubs compatible endpoint, you can also route data to custom endpoints of type Event Hubs. You could choose you favorite\u00a0programming languages to <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/event-hubs\/event-hubs-dotnet-standard-getstarted-receive-eph\">receive events from Azure Event Hubs<\/a>.<\/p>\n<h4>Reading from Service Bus queues<\/h4>\n<p>Service Bus queues used as IoT Hub endpoints must not have\u00a0<strong>Sessions<\/strong>\u00a0or\u00a0<strong>Duplicate Detection<\/strong>\u00a0enabled. If either of those options are enabled, the endpoint appears as\u00a0<strong>Unreachable<\/strong>\u00a0in the Azure portal.\u00a0You could choose you favorite\u00a0programming languages to <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/service-bus-messaging\/service-bus-dotnet-get-started-with-queues\">receive messages from the queue<\/a>.<\/p>\n<h4>Reading from Service Bus topics<\/h4>\n<p>Similar to\u00a0Service Bus queues, Service Bus topics used as IoT Hub endpoints must not have\u00a0<strong>Sessions<\/strong>\u00a0or\u00a0<strong>Duplicate Detection<\/strong>\u00a0enabled. If either of those options are enabled, the endpoint appears as\u00a0<strong>Unreachable<\/strong>\u00a0in the Azure portal.\u00a0You could choose you favorite\u00a0programming languages to <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/service-bus-messaging\/service-bus-dotnet-how-to-use-topics-subscriptions\">receive messages from the subscription<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>For more information about tooling for Azure IoT Hub in Visual Studio Code, you could checkout the <a href=\"https:\/\/github.com\/Microsoft\/vscode-azure-iot-toolkit\/wiki\">Wiki page of\u00a0Azure IoT Hub Toolkit<\/a>, we also have added a <a href=\"https:\/\/github.com\/Microsoft\/vscode-azure-iot-toolkit\/wiki\/FAQ\">FAQ page<\/a> to\u00a0collect common questions from Azure IoT Hub developers.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IoT Hub\u00a0Message Routing\u00a0enables users to route device-to-cloud messages to service-facing endpoints.\u00a0An IoT hub has a default\u00a0built-in endpoint. You can create custom endpoints to route messages to by linking other services in your subscription to the hub. IoT Hub currently supports Azure Storage containers, Event Hubs, Service Bus queues, and Service Bus topics as custom endpoints. [&hellip;]<\/p>\n","protected":false},"author":672,"featured_media":1836,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[290,1],"tags":[7],"class_list":["post-2340","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-iot-hub","category-iot-dev","tag-azure-iot-hub"],"acf":[],"blog_post_summary":"<p>IoT Hub\u00a0Message Routing\u00a0enables users to route device-to-cloud messages to service-facing endpoints.\u00a0An IoT hub has a default\u00a0built-in endpoint. You can create custom endpoints to route messages to by linking other services in your subscription to the hub. IoT Hub currently supports Azure Storage containers, Event Hubs, Service Bus queues, and Service Bus topics as custom endpoints. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/posts\/2340","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\/672"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/comments?post=2340"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/posts\/2340\/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=2340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/categories?post=2340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/iotdev\/wp-json\/wp\/v2\/tags?post=2340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}