Microsoft has been investing heavily in the pretty much every aspect of Microsoft Azure, and the IoT (Internet of Things) space is not being left out. Microsoft has innovated very nicely with services like Azure IoT Hub and the newer Azure IoT Central. These are pretty amazing cloud services within Microsoft Azure that truly ease the development and integration of IoT into any solution. Now, with the release of the “Azure IoT Extension for Azure CLI 2.0”, Microsoft is enhancing the command-line management experience for working with IoT related services within Microsoft Azure.
IoT Extension for Azure CLI 2.0
The “Microsoft Azure IoT Extension for Azure CLI 2.0” is Open Source, just like the Azure CLI itself. The Azure CLI 2.0 includes support for managing Azure IoT Hub resources, device provisioning, and linked-hubs. However, the IoT Extension enhances the Azure CLI 2.0 with additional features such as device management, and full IoT Edge capabilities!
To summarize this for easier reading and reference, here’s a quick summary of the high-level features supported:
- Azure CLI 2.0 IoT capabilities
- Manage IoT Hub instances, consumer-groups and jobs
- Manage device provisioning service instances, access-policies, Linked-hub and certificates
- New Features for the IoT Extension for Azure CLI 2.0
- Manage device and edge module identities as well as their respective twin definitions
- Query IoT Hub for info such as device and module twins, jobs and messaging routing
- Invoke device and module methods
- Generate SAS tokens, and grab Connection Strings
- Cloud-to-Device and Device-to-Cloud messaging
- Device file upload
- Device simulation for testing
- Full Edge functionality including single device and at scale deployments
- Manage DPS individual and group enrollments
It’s always great to see the tooling around any particular service expanded with additional functionality. This new IoT Extension for the Azure CLI 2.0 is really great to see. It enhances the tooling support in many ways that it was previously lacking!
With the launch of this new IoT Extension, Microsoft will now be retiring the version IoT Extension for Azure CLI 1.0 and the iot-hub-explorer tool. Currently, the Azure CLI 1.0 and CLI 2.0 are functionally in parity. All the features of iot-hub-explorer are included in the Azure CLI 2.0 IoT Extension with the exception of event monitoring commands. Support for event monitoring commands is expected to be released in early March 2018, so it should be coming soon. Also, the depreciation of the IoT Extension for Azure CLI 1.0 and the iot-hub-explorer is expected to happen by June 30, 2018.
For additional information, reference the Announcing IoT extension for Azure CLI 2.0 post by Chrissie Chi.
Install the IoT Extension for Azure CLI 2.0
First, you need to have the Azure CLI 2.0 installed. More specifically you need to be running Azure CLI version 2.0.24 or above. You can check what version of the Azure CLI 2.0 you have installed by running the following command:
Once you have verified you have the correct version of the Azure CLI 2.0 installed, you can run the following command to quickly install the extension:
az extension add –name azure-cli-iot-ext
If necessary, you can use the following command to view status of the IoT Extension that you have installed:
az extension show –name azure-cli-iot-ext
IoT Extension Examples
Here’s some examples of working with IoT resources using the IoT Extension for Azure CLI 2.0.
Create a new IoT Hub
az iot hub create –name demoHub –resource-group iotDemoGroup
Create a new device in the IoT Hub
az iot hub device-identity create –hub-name demoHub –device-id demoDevice
View the Device Twin for an IoT Device
az iot hub device-twin show –hub-name demoHub –device-id demoDevice
There’s more documentation on the commands within the IoT Extension for Azure CLI 2.0 on the Github wiki pages for the project.