Wilson Mar bio photo

Wilson Mar

Hello. Hire me!

Email me Calendar Skype call 310 320-7878

LinkedIn Twitter Gitter Instagram Youtube

Github Stackoverflow Pinterest

Get value from IoT means getting wisdom from analytics and notifications

US (English)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Cyrillic Russian   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

Overview

Here is a hands-on step-by-step guided tour to Microsoft’s IoT Hub, which runs in Microsoft’s Azure cloud (as a SaaS offering) – one of several IoT clouds I’ve looked at *

Azure IoT Hub is the foundational PaaS (Plattform as a Service) offering for device connectivity, management and communication. If an IoT device does not support standard protocols (AMPQ, MQTT and HTTP), then incoming and outgoing traffic can be adapted using the Azure IoT Protocol Gateway

Azure IoT Central provides Software as a Service (SaaS) by using an IoT Hub under the hood to provide templates that use a ready-made model-based approach to build enterprise-grade IoT solutions – without requiring expertise in cloud-solution development.

Azure IoT solution accelerators are built on Azure IoT Hub to accelerate the development of custom IoT solutions.

Azure IoT Edge extends cloud intelligence and analytics to edge devices at a local level (like AWS Greengrass), so devices can run offline. The connected device simulation accelerator allows test-run of solutions with tens of thousands of simulated devices. IoT Edge has extremely low latency and near real-time response potential. Edge works the AI Toolkit for Azure IoT Edge to run AI and ML tasks such as image recognition and complex event processing.

See https://cloudacademy.com/blog/introduction-azure-iot/ Dec 17, 2018

Azure IoT Marketing

PROTIP: Various web pages related to Microsoft’s Azure IoT ecosystem have links that point to each other, in one big circle. So here I’ve arranged the links in one page, in logical order as a hands-on guided tour.

  1. For starters, visit Microsoft’s marketing page for its various IoT offerings: https://azure.microsoft.com/en-us/overview/iot This “Azure IoT Developer Center” is also reached by http://azure.com/iotdev

    In that page there are links to reports from analysts. “DC MarketScape: Microsoft a leader in IIoT platforms for manufacturing and energy” presents this diagram showing Microsoft dominating in the Manufacturing and Energy industries:

    azure-iot-idc-2019-1280x720.png

    Use cases

  2. Microsoft built Azure IoT for scaled-up production usage by a wide range of industries. App Templates for industries Retail, Energy, Government, and Healthcare, introduced in “Azure IoT Central: Democratizing IoT for all solution builders” October 28, 2019 by Bert Van Hoof, Partner Group Program Manager, Azure IoT

  3. Read insightful blogs by Jaishree Subramania, Microsoft’s Sr. Director of Azure IoT Marketing.

  4. Digital transformation with Azure IoT learning paths by Olivier Bach on Provisioned Solutions https://www.azureiotsolutions.com/Accelerators Deploy and Operate a Remote Monitoring solution per https://docs.microsoft.com/en-us/azure/iot-accelerators/quickstart-remote-monitoring-deploy

Tutorials

There is a lot of overlap among the various tutorials.

Introduction to Azure IoT solution accelerators

  1. The most in-depth instructions for builders are at: https://docs.microsoft.com/en-us/azure/iot-hub, titled “IoT Hub Documentation”.

    PROTIP: Don’t visit https://iotschool.microsoft.com/en-us/home, the Azure “IoT School”, which contains links to “learning paths”:

    BLAH: It sends you to GitHub repositories for the actual presentation: https://github.com/Azure-Samples/azureiotlabs, which is organized around the diagram above.

  2. Among all of Microsoft’s tutorials in one menu lists by a recommended sequence from Beginner thru Intermediate to Advanced levels.

  3. Check “Learning Path”, then “Azure Fundamentals”. Taking all its modules prepares you for the Azure Fundamentals exam.

    Azure IoT Developer skill certification

    Pay $165 (while in Beta 2020) to pass the AZ-220 exam to earn the Microsoft Certified: Azure IoT Developer Specialty certification . The exam pdf details these high-level subjects:

    • Implement the IoT solution infrastructure
    • Provision and manage devices
    • Implement Edge
    • Process and manage data
    • Monitor, troubleshoot, and optimize IoT solutions
    • Implement security

Learning resources

https://iotschool.microsoft.com/en-us/home

https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/ are listed with https://docs.microsoft.com/en-us/learn/browse/?products=azure&term=iot 6 learning paths pointing to 20 modules

https://docs.microsoft.com/en-us/azure/iot-fundamentals/

https://docs.microsoft.com/en-us/azure/iot-fundamentals/iot-introduction

https://docs.microsoft.com/en-us/azure/iot-fundamentals/iot-services-and-technologies

Python

https://github.com/Azure/azure-iot-sdk-python

Install CLI, .NET with SDK

This section is described in https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_03-set-up-the-development-environment.html

  1. PROTIP: On macOS, use Homebrew to install, then validate .NET Core run-time OR .NET Core 3.x SDK INSTEAD of downloading from the downloads page:

    brew cask install dotnet or brew cask intall dotnet-sdk

    Alternately, install the dotnet-preview or dotnet-sdk-preview.

    Error: Cask ‘dotnet-sdk’ conflicts with ‘dotnet’.

    NOTE: Password is requested for dotnet install.

  2. Verify

    dotnet –version

    3.1.201

  3. In the Visual Studio Code Extension manager, search for and then install the following Extensions:

    • Azure IoT Tools (vsciot-vscode.azure-iot-tools) by Microsoft
    • C# for Visual Studio Code (ms-vscode.csharp) by Microsoft
  4. Install. See https://docs.microsoft.com/en-us/cli/azure/install-azure-cli

    rm ‘/usr/local/bin/az’ # from previous install brew remove azure-cli

    brew install azure-cli

    /usr/local/Cellar/azure-cli/2.2.0_1: 14,588 files, 156MB

    brew link azure-cli az –version | grep “azure-cli “

    2.0.77

  5. Install the Azure CLI extension for IoT,

    az extension add –name azure-cli-iot-ext

  6. Login

    az login

Introduction

https://docs.microsoft.com/learn/paths/introduction-to-azure-iot/

  • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_05-individual-enrollment-of-device-in-dps.html

  • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_06-automatic-enrollment-of-devices-in-dps.html

  • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_07-analyze-message-data-in-real-time.html

  1. https://docs.microsoft.com/learn/modules/azure-iot-strategy-and-solutions/

  2. https://docs.microsoft.com/learn/modules/introduction-iot/

    • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_01-getting-started-with-azure.html

    • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_08-visualize-data-stream-in-power-bi.html

    • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_09-iot-hub-integration-with-azure-event-grid.html

IoT Hub

Time-series Insights

  • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_10-analyze-time-stamped-data-with-time-series-insights.html

https://docs.microsoft.com/en-us/azure/time-series-insights/time-series-insights-overview

https://www.dynatrace.com/news/blog/azure-services-explained-part-3-azure-iot-hub/ Dynatrace’ Smartscape

IoT Central

IoT Central is an IoT application platform that reduces the burden and cost of developing, managing, and maintaining enterprise-grade IoT solutions.

High-level reference: Why Microsoft IoT Central is the key to your IoT success

https://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Getting-started-with-Windows-IoT-Episode-4-Azure-IoT-Hub-and-IoT-Central-Integration

https://azure.microsoft.com/en-us/services/iot-central/ build industry-leading solutions with a hosted IoT application platform.

https://docs.microsoft.com/en-us/azure/iot-central/core/overview-iot-central lists major known issues

https://docs.microsoft.com/learn/paths/develop-iot-solutions-with-azure-iot-central/

  1. https://docs.microsoft.com/learn/modules/create-your-first-iot-central-app/

    • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_20-build-with-iot-central.html
  2. https://docs.microsoft.com/learn/modules/monitor-and-manage-device-with-iot-central/
  3. https://docs.microsoft.com/learn/modules/using-iot-central-with-connected-field-service/
  4. https://docs.microsoft.com/learn/modules/set-up-rules-take-actions-telemetry-data-azure-iot-central/
  5. https://docs.microsoft.com/learn/modules/manage-iot-central-apps-with-rest-api/

IoT Edge

Azure IoT Edge moves cloud analytics and custom business logic to devices so that your organization can focus on business insights instead of data management. Scale out your IoT solution by packaging your business logic into standard containers, then you can deploy those containers to any of your devices and monitor it all from the cloud.

https://azure.microsoft.com/en-us/services/iot-edge/ Cloud intelligence deployed locally on IoT edge devices

https://docs.microsoft.com/learn/paths/build-intelligent-edge-with-azure-iot-edge/

  • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_11-introduction-to-azure-iot-edge.html

  • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_12-setup-an-iot-edge-gateway.html

  • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_13-deploy-and-debug-custom-azure-iot-edge-module.html

  • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_14-iot-edge-device-in-restricted-network.html

  1. https://docs.microsoft.com/learn/modules/introduction-iot-edge/

  2. https://docs.microsoft.com/learn/modules/train-package-module-iot-edge/
  3. https://docs.microsoft.com/learn/modules/introduction-lambda-architecture-iot-solutions/

IoT Devices

https://catalog.azureiotsolutions.com/alldevices

https://docs.microsoft.com/learn/paths/securely-connect-iot-devices/

  1. https://docs.microsoft.com/learn/modules/manage-iot-devices/

    • https://microsoftlearning.github.io/AZ-220-Microsoft-Azure-IoT-Developer/Instructions/Labs/LAB_AK_04-connect-iot-device-to-azure.html
  2. https://docs.microsoft.com/learn/modules/securely-provision-iot-devices-at-scale-with-device-provisioning-service/

Azure IoT Field Service

https://docs.microsoft.com/learn/paths/working-with-connected-field-service-iot/

Dynamics365

  1. https://docs.microsoft.com/learn/modules/register-and-manage-customer-devices-with-connected-field-service/
  2. https://docs.microsoft.com/learn/modules/identify-exceptions-with-connected-field-service/
  3. https://docs.microsoft.com/learn/modules/get-started-with-connected-field-service/
  4. https://docs.microsoft.com/learn/modules/remotely-monitor-and-service-customer-equipment/

Jump into Azure

  1. Click “Sign Up for Azure”, then click “Start”.

  2. Create an active Azure account at https://azure.microsoft.com/en-us/free/free-account-faq

    PROTIP: To get support (even via email), the minimum “Pay As You Go” Support Plans is $29/month for a Developer plan.

    The “Standard” plan for IoT is an additional $300/month.

    Call 1-800-867-1389 if you have questions.

  3. Open an Azure Subscription:

    Pricing

    Azure IoT is typically cheaper than AWS or GCP.

    IoT Hub is grouped into four tiers, up to the high throughput S3 tier for up to 300,000,000 messages per day. More can be purchased.

    After a one-month free trial period, the “F1 Free Tier” allows 8,000 free messages (of .5 KB each) a day.

    NOTE: Although messages can be up to 512 KB, they are billed in 4 KB blocks.

    The first paid tier of 400,000 messages per month / $50 = 0.000125 per message (about 1 cent).

    Login Azure

  4. Log into https://portal.azure.com/#allservices, the Azure Portal and select “Internet of Things” on the left menu for a menu of services:

    Azure IoT services list

    azure-iot-services-2184x1122.png

    https://azure.microsoft.com/en-us/services/#iot has links to the marketing page of a full list of services.

    The interaction among some of the above Azure IoT services are diagrammed below.

    Azure IoT Component flow diagram

Online Emulator

Microsoft provides an online software emulator, called the “MXChip IoT DevKit Simulator” at https://azure-samples.github.io/iot-devkit-web-simulator/

It has “Getting Started” and “Shake Shake”

  • .h header files
  • .cpp C++ code
  • .ino code
  1. To provision cloud services
  2. Connection string:

    • Ask questions about it at https://gitter.im/Microsoft/raspberry-pi-web-simulator

Thousands of issues for all IoT https://github.com/MicrosoftDocs/azure-docs/issues?utf8=%E2%9C%93&q=%227c6b3210-d878-0347-27af-199c2c00daa9%22&in=body

IoT Hardware

Many begin by buying (for $39 from Seeed.com) the MXChip AX3166 hardware depicted on the left side of the diagram above.

AZ3166-arduino-board-994x1022

It’s an Arduino chip plus a little 128x64 pixel OLED screen as well as a RGB light, working status indicator, and infrared emitter (to control TVs). Also added onboard are several sensors: temperature, detect humidity, barometric pressure, magnetometer (compass), Motion sensor (vibration).

NOTE: It does not have a camera.

Comments on Amazon about it

There is also Raspberry Pi, which have a more powerful CPU, but does not come with external sensors.

https://catalog.azureiotsolutions.com/kits lists all the IoT hardware kits compatible with Azure IoT.

  1. Join Microsoft’s IoT Tech Community at http://aka.ms/iottechcommunity (https://techcommunity.microsoft.com/t5/internet-of-things-iot/ct-p/IoT).`

    Create Resource Group in Azure Portal

    Enter IoT Hub to create a Resource Group for your local region:

  2. Enter the Azure Portal GUI at http://portal.azure.com (formerly http://ms.portal.azure.com).

  3. PROTIP: Define a Resource Group name based on your projected future scope. Avoid simple names such as “mydevice”. Include in Resource Names the service (such as “iothub”), app (with version), geography, etc. plus a sequence number such as “001”.

    Create a map to track where your devices are located.

    https://github.com/Azure-Samples/azureiotlabs/blob/master/IoTHub/README.md

  4. Click the green “+ New” at the upper left corner.
  5. Type Resource on top of “Search the marketplace”

  6. Pick “Internet of Things” from among the Azure Marketplace. Pick the “IoT Hub” on the “S1 - Standard” tier.

  7. Choose the right IoT Hub Subscription tier for your solution at https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-scaling

  8. Resource group location
  9. Click Pin to dashboard
  10. Click Create

CLI install script in Terminal

This tutorial executes in one command what other tutorials assume are several manually typed commands:

  1. Open a macOS Terminal or Windows Git Bash window.
  2. Navigate to your user home folder.

    cd $HOME
  3. Triple-click on the command below and command+C to copy it to your Clipboard, then in a macOS Terminal or Windows Git Bash window, press command+V to paste and run the installer.

    bash -c "$(curl -fsSL https://raw.githubusercontent.com/wilsonmar/mac-install/master/ms-azure-iot.sh)"
    

    PROTIP: The script was written based on my Bash Script Best Practices tutorial.

    Based on https://docs.microsoft.com/en-us/cli/azure/install-az-cli2
    or https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
    = https://go.microsoft.com/fwlink/?linkid=848173

Here’s what happens within the script, as if you’re doing it manually:

  1. Install Python and pip.
  2. Install Homebrew.
  3. Install the Azure CLI:

    pip install --user azure-cli

    Alternatively,

    brew install azure-cli 
    

    The response at time of writing:

    ==> Installing dependencies for azure-cli: python3
    ==> Installing azure-cli dependency: python3
    ==> Downloading https://homebrew.bintray.com/bottles/python3-3.6.3.sierra.bottle
    ######################################################################## 100.0%
    ==> Pouring python3-3.6.3.sierra.bottle.tar.gz
    ==> /usr/local/Cellar/python3/3.6.3/bin/python3 -s setup.py --no-user-cfg instal
    ==> /usr/local/Cellar/python3/3.6.3/bin/python3 -s setup.py --no-user-cfg instal
    ==> /usr/local/Cellar/python3/3.6.3/bin/python3 -s setup.py --no-user-cfg instal
    ==> Caveats
    Pip, setuptools, and wheel have been installed. To update them
      pip3 install --upgrade pip setuptools wheel
     
    You can install Python packages with
      pip3 install <package>
     
    They will install into the site-package directory
      /usr/local/lib/python3.6/site-packages
     
    See: https://docs.brew.sh/Homebrew-and-Python.html
    ==> Summary
    🍺  /usr/local/Cellar/python3/3.6.3: 3,588 files, 56.1MB
    ==> Installing azure-cli
    ==> Downloading https://homebrew.bintray.com/bottles/azure-cli-2.0.18.sierra.bot
    ######################################################################## 100.0%
    ==> Pouring azure-cli-2.0.18.sierra.bottle.tar.gz
    ==> Caveats
    This formula is for Azure CLI 2.0 - https://docs.microsoft.com/cli/azure/overview.
    The previous Azure CLI has moved to azure-cli@1
    ----
    Get started with:
      $ az
     
    Bash completion has been installed to:
      /usr/local/etc/bash_completion.d
    ==> Summary
    🍺  /usr/local/Cellar/azure-cli/2.0.18: 7,181 files, 40MB
    

    Do the above instead of the old way:

    curl -L https://aka.ms/InstallAzureCli | bash
    

    which outputs:

    ===> In what directory would you like to place the install? (leave blank to use '/Users/mac/lib/azure-cli'): 
     
    ===> Modify profile to update your $PATH and enable shell/tab completion now? (Y/n): 
     
    ===> Enter a path to an rc file to update (leave blank to use '/Users/mac/.bash_profile'): 
    

    Automate Azure Portal

    Actions can be made repeatable by automation.

    Most actions in Azure can be automated using the CLI (Command Line Interface). For example, creating an Azure Resource Group is a single command such as:

    az group create -n cli-rg \
    -l westeurope

    NOTE: Location is also called region.

    Also:

    az iot hub create --resource-group your-RG \
    --name yourname \
    --location yourlocation

    Bash_profile every terminal

  4. Reset the Terminal:

    source ~/.bash_profile
    

    Alternately, restart command shell:

    exec -l $SHELL
    

    az commands

  5. As recommended, list the commands:

    az
    

    Expand the screen to see it all:

    Welcome to Azure CLI!
    ---------------------
    Use `az -h` to see available commands or go to https://aka.ms/cli.
     
    Telemetry
    ---------
    The Azure CLI collects usage data in order to improve your experience.
    The data is anonymous and does not include commandline argument values.
    The data is collected by Microsoft.
     
    You can change your telemetry settings with `az configure`.
     
    Welcome to the cool new Azure CLI!
     
    Here are the base commands:
     
     account          : Manage Azure subscription information.
     acr              : Manage Azure Container Registries.
     acs              : Manage Azure Container Services.
     ad               : Synchronize on-premises directories and manage Azure Active Directory
                        resources.
     appservice       : Manage App Service plans.
     backup           : Commands to manage Azure Backups.
     batch            : Manage Azure Batch.
     billing          : Manage Azure Billing.
     cdn              : Manage Azure Content Delivery Networks (CDNs).
     cloud            : Manage registered Azure clouds.
     cognitiveservices: Manage Azure Cognitive Services accounts.
     component        : Manage and update Azure CLI 2.0 components.
     configure        : Display and manage the Azure CLI 2.0 configuration. This command is
                        interactive.
     consumption      : Manage consumption of Azure resources.
     container        : (PREVIEW) Manage Azure Container Instances.
     cosmosdb         : Manage Azure Cosmos DB database accounts.
     disk             : Manage Azure Managed Disks.
     dla              : (PREVIEW) Manage Data Lake Analytics accounts, jobs, and catalogs.
     dls              : (PREVIEW) Manage Data Lake Store accounts and filesystems.
     eventgrid        : Manage Azure Event Grid topics and subscriptions.
     extension        : Manage and update CLI extensions.
     feature          : Manage resource provider features.
     feedback         : Loving or hating the CLI?  Let us know!
     find             : Find Azure CLI commands.
     functionapp      : Manage function apps.
     group            : Manage resource groups and template deployments.
     image            : Manage custom virtual machine images.
     interactive      : Start interactive mode.
     iot              : (PREVIEW) Manage Internet of Things (IoT) assets.
     keyvault         : Safeguard and maintain control of keys, secrets, and certificates.
     lab              : Manage Azure DevTest Labs.
     lock             : Manage Azure locks.
     login            : Log in to Azure.
     logout           : Log out to remove access to Azure subscriptions.
     managedapp       : Manage template solutions provided and maintained by Independent Software
                        Vendors (ISVs).
     monitor          : Manage the Azure Monitor Service.
     mysql            : Manage Azure Database for MySQL servers.
     network          : Manage Azure Network resources.
     policy           : Manage resource policies.
     postgres         : Manage Azure Database for PostgreSQL servers.
     provider         : Manage resource providers.
     redis            : Access to a secure, dedicated Redis cache for your Azure applications.
     resource         : Manage Azure resources.
     role             : Manage user roles for access control with Azure Active Directory and service
                        principals.
     sf               : Manage and administer Azure Service Fabric clusters.
     snapshot         : Manage point-in-time copies of managed disks, native blobs, or other
                        snapshots.
     sql              : Manage Azure SQL Databases and Data Warehouses.
     storage          : Manage Azure Cloud Storage resources.
     tag              : Manage resource tags.
     vm               : Provision Linux or Windows virtual machines.
     vmss             : Manage groupings of virtual machines in an Azure Virtual Machine Scale Set
                        (VMSS).
     webapp           : Manage web apps.
     
  6. Query using the az commands

    az 
    

    PROTIP: Drag the right edge of your Terminal window wider to avoid line wrap.

    Secrets pre-configuration

    The script makes a folder path “$HOME/gits/wilsonmar/mac-install” by git clone https://github.com/wilsonmar/mac-install.git

  7. The script stops if it does not see a file that defines credentials to access Azure cloud.

  8. Create a file in that folder to define your account and password. The script will execute the file to retrieve their values for use within the script. If this file is not in your laptop’s user home folder, the script stops.

  9. After you establish the secrets file, run the script again.

    az login

  10. Login using command:

    az login -u johndoe@someorg.com -p MySecret
    

    If the user and password are not specified, an interactive dialog appears.

  11. Authenticate: use a web browser to open page (command az) https://aka.ms/devicelogin to enter code E946P2YFU.

    Click Continue at “Microsoft Azure Cross-platform Command Line Interface”.

    Login to see on the Terminal:

     "cloudName": "AzureCloud",
     "id": "4effab90-7516-4bdb-902a-18001facad69",
     "isDefault": true,
     "name": "Developer Program Benefit",
     "state": "Disabled",
     "tenantId": "12345678-5f96-4d36-a89b-5ea0f7614e72",
     "user": {
       "name": "your@hotmail.com",
       "type": "user"
    
  12. List the default subscription associated with your login:

    az account list
  13. View the subscription being used to create resources in:

    az account show
  14. Set a second subscription account:

    az account set --subscription "[name of second account]"

    IoT Hub Explorer

    The iothub-explorer is a CLI tool for managing device identities in your IoT hub registry, send and receive messages and files from your devices, and monitor your IoT hub operations.

    The iothub-explorer tool also lets you simulate a device connected to your IoT hub.

    To get started with iothub-explorer using the Visual Studio Code command line:

  15. Install Node.js
  16. Install the latest version from any folder:

    npm install iothub-explorer -g
    
  17. Verify by getting a menu:

    iothub-explorer --help
    
  18. PROTIP: Edit on your Mac’s boot-up file:

    source ~/.bash_profile
    
  19. Add this line to create a custom alias, then save the file:

    alias aih='iothub-explorer'

    NOTE: You can select another alias short name than this example.

  20. Close your Terminal and open it again or, alternately:

    source ~/.bash_profile
    
  21. Now you can verify using an alias:

    aih --version
    

C# Simulator

  1. Install a Simulator in the C# HubExplorer

    https://azure-samples.github.io/raspberry-pi-web-simulator/build/index.html

    https://azure-samples.github.io/raspberry-pi-web-simulator

    The left pane is the Assembly Area.
    The right top pane is the Coding Area.
    The right bottom pane is called the Integrated console window displaying output.

    1. Select the device just created to copy the primary key of its connection string.

    2. Click Run button or type “npm start” in the console window to run the application.

Azure access from a mobile phone

https://apps.apple.com/app/microsoft-azure/id1219013620?ls=1

Windows 10 Device Explorer app for IoT Hub devices

Use the Device Explorer tool (on Windows 10 only) to manage devices connecting to your IoT hub. For example, you can use this tool to register a device with your IoT hub, monitor messages from your devices, and send messages to your devices. This is not the same as the Device Explorer blade that you can open from your IoT Hub service on the Azure portal.

The Device Explorer app runs on your local machine and connects to your IoT hub in Azure. It communicates with the following IoT Hub endpoints:

  • Device identity management to provision and manage devices registered with your IoT hub.

  • Receive device-to-cloud to enable you to monitor messages sent from your device to your IoT hub.

  • Send cloud-to-device to enable you to send messages to your devices from your IoT hub.

Event Grid

The Azure Event Grid is like a transportation hub where buses and trains and cars and planes come together to be scattered again.

iot-hub-event-grid-1753x972.png

The Event Grid receives from Event Sources and routes them to Event Handlers.

  1. Get emulator event info to be “captured” by the Event Grid.

    Subscribe your IoTHub to EventGrid as event source

  2. Configure the “MXChip” IoT device’s event info to be “captured”.

    https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-arduino-iot-devkit-az3166-get-started

    https://github.com/Azure-Samples/azureiotlabs/blob/master/automaticdeviceconfiguration/README.md Configure and monitor IoT devices at scale</a>

    https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-device-management-overview#device-lifecycle Overview of device management with IoT Hub (published 08/23/2017)

  3. Get the Event Grid to notify a Logic App to send mail.

  4. Load test using Device Simulator

Data from devices are analyzed using various technologies:

  • The stream of event data are analyzed and presented in Time Series Analysis visualizations that lead to insights about the business and its technologies.

  • Stream Analytics stores “Hot Path Analytics” data in a Microsoft Cosmos DB (DataBase) within the Microsoft’s Azure cloud.

  • Historical data not referenced immediately are stored in >Cold Path Storage within a Data Lake Store, which are analyzed using Batch Analytics.

References

  • https://internetofyourthings.com
  • aka.ms/iotbestpractices
  • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-security-deployment
  • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-security-ground-up
  • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-security-best-practices
  • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-security-architecture
  • https://www.enisa.europa.eu/publications/etl2015 - mindmap of threats


Raspberry Pi Config

  1. Get an IoT device: Intel Edison or Raspberry Pi (azureiotsuite.com)

    https://catalog.azureiotsuite.com/kits = https://aka.ms/edx-dev225x-az1

    In the Adafruit kit:

    • Assembled Adafruit BME280 Temperature, Pressure & Humidity sensor
    • Photo cell (CdS photoresistor)
    • 2x 560 ohm 5% 1/4W Resistor (striped green, blue, brown)
    • Ceramic Capacitor (0.1uF)
    • Diffused 10mm Red LED
    • Diffused 10mm Green LED
    • Male/Male Jumper Wires - 20 x 6” (150mm)
    • Female/Male ‘Extension’ Jumper Wires - 20x6” (150mm)
    • Full Size Breadboard

  2. Connect

    https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-raspberry-pi-web-simulator-get-started Connect Raspberry Pi online simulator to Azure IoT Hub (Node.js)

    New IoT Hub service

  3. Click the green “+ New” at the upper left corner.
  4. Type IoT on top of “Search the marketplace” to select IoT Hub.
  5. Click on the IoT Hub icon.

    iot-azure-iot-hub com

  6. Click the blue Create button.
  7. Click “Sign-up for an Azure subscription” if that comes up.

    PROTIP: For each email, you get one month free to use the $200.

  8. Add a hub Name beginning with “IoT”…
  9. Select the F1 free tier or
  10. Begin with 1 partition for Device-to-cloud.
  11. Select a Location closest to you (US-West or US-East-1).
  12. Check Pin to dashboard.
  13. Click Create.

    CAUTION: Each hub consumes credits (money) regardless of usage.

    https://docs.microsoft.com/en-us/azure/iot-hub/
    Documentation

  14. Name is unique across all accounts in Azure. A red ! appears on the right of the field if it’s not.
  15. Pricing and scale tier: F1 for free to highlight it as yellow.
  16. Click Select.
  17. IoT Hub units: 1.
  18. Device-to-cloud partitions: 2.
  19. Subscription:
  20. For Resource group, use existing and select it.
  21. Check Pin to dashboard.
  22. Click Create.
  23. Look at the running bar under the Navigation bell at the upper-right corner until “Deployment succeeded” appears.
  24. You may need to select Refresh to see the recently created resource group.

    Activation (optional)

  25. PROTIP: Make inactive.

  26. Re-activate the hub for steps below.

    Resource Group

  27. Click Resource Group on the left menu.
  28. Click on the hub defined.
  29. Click on Shared access policies
  30. Select iothubowner
  31. Click on the icon to copy the Connection string – primary key credentials. “Copied” appears.

    Permissions on the secondary key can be changed.

  32. Open a Notepad
  33. Paste this into the Notepad and note that this is the credential to the IoT Hub as full administrator

    Device Explorer

  34. Click Device Explorer in the IoT Hub menu.
  35. Click on the “+ Add” to add new devices and credentials.
  36. Device ID: (myFirstNodeDevice) Enter this name exactly as myFirstNodeDevice
  37. All other fields are left to default
  38. Click Save.

    Create Device Entries for Web001

Use the Device Explorer option to view, create, update and delete devices on the IoT Hub.

  1. Click on Device Explorer.
  2. Click on the “+ Add” to add new devices and credentials.
  3. Device ID: (Web001) Enter this name exactly as Web001
  4. All other fields are left to default.
  5. Click Save.

    Gather Device Credentials

    Delete a device

    az iot hub delete --name yourname --resource-group yourRG 
    

    List devices

    az iot device -h
    

    Create an IoT Hub service

  6. Clone an Azure IoT service SDK

    WARNING: These repos contain sub-modules, so add to git clone commands --recursive.

    PROTIP: Since we won’t be uploading changes, we don’t fork and we also add to the command --depth=1.

    • https://github.com/azure/azure-iot-sdk-python (2.7 and 3.5) - 195 M - Video

    • https://github.com/azure/azure-iot-sdk-node - 45 M - Video

    • https://github.com/azure/azure-iot-sdk-java (1.7+) - 49 M -

    • https://github.com/azure/azure-iot-sdk-csharp (C#) for .NET and UWP (Universal Windows Platform) - 57 M -

    • https://github.com/azure/azure-iot-sdk-c for microcontrollers such as RTOS - 60M - Video

    PROTIP: The smallest is Node.

  7. NOTE: The rest of this tutorial uses Python, so:

    cd azure-iot-sdk-python
    
  8. PROTIP: See how much disk space is used by the new folder. On a Mac:

    du -sh
    

    For Python I got 155 M (Megabytes) using --depth=1 versus 195 M with all history.

  9. PROTIP: In the future, to obtain changes to the repo by Microsoft:

    git pull
    

    Create an IoT device and register it with your IoT Hub

    https://youtu.be/wvRE5nvX8GQ by linkedin.com/in/arjmand-samuel-7919934

  10. WARNING: Device names must be unique across all Azure customers. So a GUID.

    The Free tier limits you to one IoT Hub (1 unit) per subscription.

  11. Set Device-to-cloud partitions at 2.

  12. Resource group (unique to your own account):

    https://go.microsoft.com/fwlink/?linkid=848172

    https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-raspberry-pi-kit-node-get-started

    Install Linux Simulator

  13. On Windows 10, install Linux inside Windows by installing the “Windows Subsystem for Linux” (beta as of May 2017) at

    https://go.microsoft.com/fwlink/?linkid=848175

    https://msdn.microsoft.com/en-us/commandline/wsl/install_guide

    Create a user

  14. In the Linux environment, run:

    chmod 555 *
    ./deploy.sh -l
    

    https://github.com/Azure/azure-cli

    Adafruit breadboard

    See video

    Config IoT Device

    On the IoT device (Raspberry Pi):

  15. Open a Terminal window and paste the below:

    git clone https://github.com/codefoster/simple-iot-hub
    cd simple-iot-hub
    

    Alternately, Node.js files from Ken Stroker (stkent@microsoft.com)

    https://github.com/kentstroker/IoT-Live-2017

  16. View file device/index.js. With Node, the entirety is in that file.

  17. To have the Pi’s LED blink and send up a picture to IoT Hub:

    git clone https://github.com/codefoster/iot-workshop
    cd iot-workshop
    

    and simple-iot-hub

    Uses GPIO pins 26 and 20.

    Tutorial

  18. Download folder Mod1Lab4. It contains:

    • deploy.sh contains deployment credentials and the connection string to the IoT Hub

    • CMakeLists.txt defines how the code should be built, and also specifies the dependencies of the C code (including the Azure IoT C SDK libraries that are used to facilitate communication with the IoT Hub).

    • main.c

    • bme280.c and bme280.h is used to take measurements from the temperature/pressure/humidity sensor

    • wiring.h is a C header file that makes it easier for you to run the same app on either a Raspberry Pi or a PC

    Video

  19. Edit deploy.sh to customize the device string used to communicate with a hub. For example:

    HostName=edxiothub-chrishowd-2.azure-devices.net;
    DeviceId=testDevice;
    SharedAccessKey=GB1QcIEu49BuoyDSSbSav+uiXKV1ewgetj7sIy2Q7xI="
    
    HostName=iotzzz.azure-devices.net;
    SharedAccessKeyName=service;
    SharedAccessKey=3k32dkba35EGffd...2viib2gg=
    
  20. Edit the IP address.

    QUESTION: What about IPV6 address?

    Send telemetry data from your device to the IoT Hub

    Azure IoT Hub Service

    The Azure IoT Hub service provides the device-to-cloud and cloud-to-device messaging capabilities and acts as the gateway to the cloud and the other key IoT Suite services. The service enables you to receive messages from your devices at scale, and send commands to your devices.

    The service also enables you to manage your devices. For example, you can configure, reboot, or perform a factory reset on one or more devices connected to the hub.

    IoT Suuite

    The Hub service is core to the Azure IoT Suite.

    See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messaging

Azure IoT Gateways

The simple version [2]:
iot-azure-arch-650x348-75kb

Raspberry Pi’s can communicate using these directly supported protocols:

  • HTTP (synchronous waits)
  • AMQP (asychrononous but heavy feature set)
  • MQTT (lower overhead and simpler, but less feature rich, less secure) - 256 bytes or it’s a file upload/download.

A more complex version [1]:

IoT Gateway

Different protocols

iot-azure-gateways-610x301
(Click for full screen picture pop-up)
  1. TODO: Get it:

    git clone https://github.com/azure/azure-iot-gateway-sdk --depth=1
    cd azure-iot-gateway-sdk
    

    Video by Chipalo Street (cstreet@micosoft.com)

    • Connect new and legacy devices
    • Run edge analytics
    • Enable time-sensitive decisions
    • Reduce bandwidth costs - fall back to least cost
    • Operate more reliably
    • Maximize Security

    Filter

    Listen for BLE (Bluetooth Low Energy) messages

  2. Get the repo described in :

    git clone https://github.com/17minds/gateway --depth=1
    cd gateway
    

    Video

    Stream Analytics

    Azure Stream Analytics provides “in-motion” data analysis. IoT Suite uses this service to process incoming telemetry, perform aggregation, and detect events.

    Preconfigured solutions use stream analytics to process informational messages that contain data such as metadata or command responses from devices.

    • Remote monitoring (RMsolution) [2:50]

    https://youtu.be/Tg_RZMXHYj8 by (corywink@microsoft)

    • Predictive Maintenance

    Solutions use Stream Analytics to process the messages from your devices and deliver those messages to other services.

    Create a Stream Analytics job that monitors data received by the IoT Hub.

    Hands-On with Azure Stream Analytics by Jeff Prosise (@jprosise) blogger/co-founder at Wintellect.

    1 Streaming Unit (SU) ~= 1 MB/sec.

    Route Output to Event Hub

    Video

    messageType = ‘a’

    Routing to functions

    Azure Functions are small chunks of code invoked based on a trigger that’s paid for only when it’s running vs. Stream Analytics

    C#, F#, Node.js, Python, PHP, batch, bash, or any executable.

    It connects to many services, such as send an email when a sensor reading exceeds a configured threshold value.

    Video to Create your first function

    Azure Functions Developer Guide has templates:

    • BlobTrigger - Process Azure Storage blobs when they are added to containers. You might use this function for image resizing.
    • EventHubTrigger - Respond to events delivered to an Azure Event Hub. Particularly useful in application instrumentation, user experience or workflow processing, and Internet of Things (IoT) scenarios.
    • Generic webhook - Process webhook HTTP requests from any service that supports webhooks.
    • GitHub webhook - Respond to events that occur in your GitHub repositories.
    • HTTPTrigger - Trigger the execution of your code by using an HTTP request.
    • QueueTrigger - Respond to messages as they arrive in an Azure Storage queue.
    • ServiceBusQueueTrigger - Connect your code to other Azure services or on-premises services by listening to message queues.
    • ServiceBusTopicTrigger - Connect your code to other Azure services or on-premises services by subscribing to topics.
    • TimerTrigger - Execute cleanup or other batch tasks on a predefined schedule.

    Message Routing

    iot-azure-messagerouting-610x256

    Video

    https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messaging

    Remote Management of Devices

    • Implement a Direct Method on your IoT device and then trigger the method remotely

    • Implement a Firmware Update using a Direct Method and monitor progress of the operation using a Device Twin

    iot-azure-device-twin-650x347

    Queries:

    Among device management plans:
    iot-azure-device-mgmt-650x298-65kb.png

    Create a Cosmos DB storage account

    • Use an Azure Stream Analytics (SA) query job to store telemetry data then make it available for analysis.

    Azure blog Storage and Azure Cosmos DB provide a pre-configured solution to store telemetry

    Azure Cosmos DB stores device metadata and enables device management.

    Video: Device Management lifecycle:

    1. Plan
    2. Provision
    3. Configure
    4. Monitor
    5. Retire

    Job

  3. In Azure, create a new job.

    Query:

    SELECT * INTO blob FROM iotmva
  4. Add Output.

    Storage options:

    • Azure SQL Database can be used as an output for data that is relational in nature or for applications that depend on content being hosted in a relational database. Stream Analytics jobs will write to an existing table in an Azure SQL Database. Note that the table schema must exactly match the fields and their types being output from your job. An Azure SQL Data Warehouse can also be specified as an output via the SQL Database output option as well (this is a preview feature).

    • Blog storage offers a cost-effective and scalable solution for storing large amounts of unstructured data in the cloud.

    • Table storage offers highly available, massively scalable storage, so that an application can automatically scale to meet user demand. Table storage is Microsoft’s NoSQL key/attribute store which one can leverage for structured data with less constraints on the schema. Azure Table storage can be used to store data for persistence and efficient retrieval.

    • DocumentDB (shown in the EDX course)

    • Data Lake Store stores data of any size, type and ingestion speed for operational and exploratory analytics. Stream Analytics needs to be authorized to access the Data Lake Store.

    • Event hub s a highly scalable publish-subscribe event ingestor. It can collect millions of events per second. One use of an Event Hub as output is when the output of a Stream Analytics job inputs into another streaming job.

    • Service bus Topics provide a one-to-many form of communication. While Service Bus Queues.

    • Service Bus Queues provide a one to one communication method from sender to receiver with a First In, First Out (FIFO) message delivery. Typically, messages are expected to be received and processed by the receivers in the temporal order in which they were added to the queue, and each message is received and processed by only one message consumer.

    • Azure Cosmos DB is a fully-managed NoSQL document database service that offers query and transactions over schema-free data, predictable and reliable performance, and rapid development.

    Power BI Visualization

    Power BI can be used as an output for a Stream Analytics job to provide for a rich visualization experience of analysis results. This capability can be used for operational dashboards, report generation, and metric driven reporting.

    Azure Web Apps and Microsoft Power BI provide data visualization capabilities.

    The flexibility of Power BI enables you to quickly build your own interactive dashboards that use IoT Suite data.

    Video

    • Use the Power BI service to view live data coming from your IoT device

References

This summarizes and adds to these blogs and classes:

[1] Developer’s introduction to Azure IoT by Olivier Bloch Senior Program Manager, Azure IoT on March 23, 2016

[2] Microsoft Virtual Academy’s Introduction to Azure IoT published 4 May 2017 is by Jeremy Foster, who has written on Pi extensively at codefoster.com/pi

  1. Introduction to Azure IoT
  2. Introduction to IoT Hub
  3. Creating a Hub, Pricing, and Scale
  4. Device Registry
  5. Protocols and Security - aka.ms/iotarch,

  6. D2C and C2D Messaging
  7. Devices and Kits
  8. Accessing the GPIO
  9. The Gateway SDK
  10. Device Management
  11. Stream Analytics and Routing
  12. Storage and Virtualization

It shows use of the C# SDK.

[3] A more in-depth (4-month) course on EdX shows use of NodeJS, Azure, the C language SDK. The video course (with quizzes) is free unless you want verification for $99. Instructors are Geoffrey Morgan ( @geoffmmorgan) of Crank211.com and Chris Howd, Engineer and Software Developer, Microsoft

Module 1: Getting Started, Setup Hub.
Module 2: Stream Analytics. Azure Functions. SendGrid.
Module 3: Data storage using DocumentDB, PowerBI
Module 4: Device management device methods, Device Twins, Firmware Update

[4] Using Microsoft Azure* IoT Suite with Intel® IoT Technology Intel blog 1 June 2016.


https://sandervandevelde.wordpress.com/2017/03/27/getting-started-with-azure-cli-2-0/ Getting started with Azure Command Line Interface 2.0

https://sandervandevelde.wordpress.com/2017/04/02/working-with-iot-hub-using-azure-command-line-interface/ Working with the IoT Hub using Azure Command Line Interface

https://sandervandevelde.wordpress.com/2017/05/04/azure-cli-made-easy-using-the-shell/ Azure CLI made easy. Using the shell

https://docs.microsoft.com/en-us/cli/azure/?view=azure-cli-latest Azure Command-Line Interface (CLI) Full reference

Build Azure IoT Modules using Azure Devops Agent in Arm32v7 architecture

More on IoT

This is one of a series on IoT:

  1. IoT Acronymns and Abbreviations

  2. IoT Apprentice school curriculum
  3. IoT use cases
  4. IoT reminders prevent dead mobile battery
  5. IoT barn feeder

  6. IoT text to speech synthesis
  7. IoT AWS button
  8. Intel IoT
  9. IoT Raspberry hardware
  10. IoT Raspberry installation

  11. IoT Clouds
  12. Samsung IoT Cloud

NOTE: Pages about GE’s Predix have been removed.