.NET Core on IoT: Az-IoTHub-PS ... The IoT Hub Quickstart Apps
iot powershell dotnetcore iothub azure iot-core devicestreaming telemetry rpi
This repository has a copy of the Azure IoT Hub SDK Quickstart .NET Core apps folder. It has been modified so that all apps get the Hub Connection strings from enviroment variables, that can be set by the PowerShell script in dicussion here. The script can also direct you to the folder for each quickstart upon selection from a menu.
These have been previously discussed on this blog here. Inbrief, these are presented as .NET Core apps (to be compiled and run). You need to supply Hub connection strings for the apps.The Quickstarts are discussed on Microsoft Documents are, (.NET versions are linked):
- Send TELEMETRY from a device to an IoT hub and read it with a back-end application .NET
- CONTROL a device connected to an IoT hub .NET
- Communicate to a device application in C# via IoT Hub DEVICE STREAMS preview
- Enable SSH and RDP over an IoT Hub DEVICE STREAM by using a C# PROXY application
The Quickstarts in this repository are a copy of those as used in the Quickstarts dicusssion on Microsoft Documents linkto the code zipfile here. Some apps (the Telemetry ones) have been modified to take the required connection strings from environment variables as does, for example the Device Streaming Echo app. An app has been added with similar functionality to the Device Streaming Echo app that upeercases the text returned from the device. Another Decice Streaming pair of apps were added where the device take three character commands from the service and sends a response back (tem for temperature, pre for pressure, etc). Other apps will be added including one that uses RPI hardware. The apps have also been modified to wait at the end for user input and with some to wait at the start.
The get-iothub script can direct you to these versions from the main menu option 6. Run Quickstart Apps:.
A Z U R E I o T H U B - R U N Q U I C K S T A R T A P P S using PowerShell AND Azure CLI|
Subscription :"Visual Studio Ultimate with MSDN"
Select a Quickstart Pair
Please make a (numerical) selection .. Or [Enter] if previous selection highlighted.
Selecting one of the Quickstarts as above will do a CD to the named folder under PS\Quickstarts and exit there so that that Quickstart can be run. You can change directory to the device or service folder and run the app there also using
dotnet run. Alternatively, there is a script
run-apps.ps1 to simulatenously run the device and service in separate shells in the folder that contains both apps (One deep from Quickstarts).
Note:»Before doing this, set the hub connection strings environment variables from the menu option 5. Generate Environment Variables from the main menu option first. Select 1. Generate Environment Variables from that menu.See below
The Quickstart folders as per this repository on GitHub at djaus2\az-iothub-ps
- The apps have been updated to use .NET Core 3.1
- The apps have been modified so that the hub connection strings are read from the environment variables.
After selecting or generating the Hub and Device, you can generate all of the connection strings required by all of the apps, as enviroment variables.These can be used directly as-is if used in the script context. (That is from the same command prompt as the script, especially when you navigate to apps via the Quickstart menu option). These can also be saved as a PowerShell script set-env.ps1 and can be placed in a variety of locations. When run, this script resets the env variables to those for the hub and device that was used to generate the script. The set-env script can also be loaded from the get-iothub context.
Note that the when the script starts it now automatically reloads the environament settings and app settings that are present as
app-settings.ps1 that are in the root folder of the script. App settings are the current Subscription, Group, Hub and Device as well as some of the Az queries.
- Running the az-iothub-ps script on a RPI
- Some RPI apps that use hardware as part of the Quickstarts
|This Category Links|
|Next: >||.NET Core on IoT||Using the PS Script to run Quickstarts on RPi (IoT-Core)|
|< Prev:||.NET Core on IoT||Use the PS Script to set up .NET Core|