The az-iothub-ps PowerShell tool was developed to support the Azure IoT Hub and Device creation, management as well as the generation of the runtime json file with connection details for .NET Core Azure IoT Hub SDK Quickstarts, in a menu driven manner. The tool has now been extended for Azure Sphere where DPS (Device Provisioning Service) or IoT Central are used. The tool has now been extended to orchestrate the creation of the required elements, collection of the required connection metadata. The outcome is the generation of the app_manifest.json file required for AzSphere apps. There are some issues though …

The djaus2/az-iothub-ps GitHub repo

This is a series in 4 parts:

  1. az-iothub-ps Extensions
  2. Intro and AzSphere commands via PowerShell using az-iothub-ps (this)
  3. Azure Sphere and DPS (coming)
  4. Azure Sphere and IoT Central cComing)

At the moment the Device Provisioning Service (DPS) appoach is implemented totally using the AzSphere and Azure Cli APIs scripting except for one step that requires access to the relevant portal. For IoT Central, a lot less of the APIs process is currently automated in scripting due to the APIs being more limited, requring more access to the relevant portal. Where the portal is required, HowTo dialogs pop up with a screen dump of the relevant part of the portal, with annotations for the required steps. Each macro step has its own HowTo. Some automation is implemented where values are copied back to the script and used by it automatically. It is hoped in the future to fully automate the IoT Central process as much as is possible, using AzSphere, Azure Cli and Rest commands.


N.b. This is a continuance of az-iothub-ps Extensions including some updates here, to the tool.


Azure Sphere Commands via PowerShell

Most of the main device management commands have been implemented in az-iothub-ps in a menu driven manner. This includes the Azsphere command prompt as a PowerShell prompt. From the tool’s main menu, select option A. Azure Sphere at he bottom. You get the following menu options:

  A Z U R E  I o T  H U B     A Z U R E  S P H E R E   using PowerShell AND Azure CLI

     Subscription :"Visual Studio Ultimate with MSDN"
            Group :"StreamMeUp"
              Hub :"AzSphere100Hub"
              DPS :"AzSphere100DPS"
 ------------------------------------
      Tenant Name :"Sportronics"
           Tenant :"bfbe8861-c64c-4eae-a3f2-9adf312d2efd"
     DPS ID Scope :"0ne000F1084"
 IoT Hub DNS Name :"AzSphere100Hub.azure-devices-provisioning.net"
Using Short Menu

Select a    A Z U R E  S P H E R E   option:

A. Enter Azure Sphere Developer Command Prompt (PS Version)
L. Login to Azure Sphere
T. Tenat
W. WiFi
U. Update
D. App Dev settings
H. Connect via IoT Hub
C. Connect Via IoT Central: Azure-Sphere-Learning-Path

Before doing anything at all you need to take the first option A. to open the AzSphere shell and login. az-iothub-ps is now running in the azsphere context. The second option L. is not required but is there in case you need to separately login to AzSphere.

You can then run most of the Tenant, WiFi, Update and App Development commands in their submenus. The commands available here are most of the commands covered in the AzSphere Quickstarts.

The Connect Commands

These will be covered in detail in the next two articles in this series. H. covers connecting an AzSphere to an IoT Hub via DPS. The second, C. covers connecting an AzSphere via IoT Central. It uses the Dave Glover’s Azure-Sphere-Learning-Path tutorial context. With both of these the outcome is the required elements (an IoT Hub, DPS, IOT Central App etc), extracting the connectivity metatdata and generating a json file that can be placed in a project so that this metadata is read and used when the app starts on the AzSphere device.

N.b. Claim Your Device Tenant Command

One command, *Claim your device* is on the Tenant menu but is not implemented. That menu option just shows you what command is required at the command prompt. Copy it and exit the tool. Then run the command there after due considerations: It is done in this way to avoid it being run as part of the tool. Whilst you do need to do it to do anything at all with the device, it is an indelible action. It is a once-only action. It is an irreversable action. You cannot undo it. Think of it as fuse bing blown in the hardware. Once it is actioned, you are locked into using that tenant forever with that device!

THIS IS ONE REASON WHY THE AZURE SPHERE IS SO SECURE. No one else can get it and hack it!

Tenant Commands

T. Get Tenant
L. List Tenants
S. Set Tenant
V. Validate Tenant
B. Back

WiFi Commands

W. Get WifI Status
S. Scan WiFi Networks
A. Add a WiFi Network
L. List and Select an added Wifi Network
F. Forget an added Wifi Network
E. Enable selected WiFi Network
D. Disable selected WiFi Network

Update Commands

O. Show OS Version
U. Get Update Status
R. Restart Device

App Dev settings

E. Enable Development
A. App Show Status
P. App Stop
S. App Start
D. Existing app sideload Delete
R. Restart Device
V. Show Security Services
T. Show Attached
G. Show Deployment Status
Y. Get Capability Configuration

NOTE THAT THESE COMMANDS ARE MENU DRIVEN!

Other AzSphere Commands

If you need to run any other Azsphere commands not covered here, just exit from teh tools and run it from teh command line. Upon exit, you are still logged into AzSphere.


 TopicSubtopic
  Next: > Azure Sphere Projects
<  Prev:   Azure Sphere
This Category:Azure Sphere
  Next: > Azure Sphere Projects Azure Sphere Getting Started 
<  Prev:   Azure Sphere