Monitor device connectivity using Azure CLI
Use the Azure CLI IoT extension to:
- See the messages your devices are sending to IoT Central.
- Observe changes in the device twin.
- Diagnose issues where device messages don't reach the cloud.
- Diagnose issues where devices don't respond to twin changes.
Visit the Azure CLI extensions reference for more details
Prerequisites
A work or school account in Azure, added as a user in an IoT Central application.
Prepare your environment for the Azure CLI
Use the Bash environment in Azure Cloud Shell. For more information, see Quickstart for Bash in Azure Cloud Shell.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.
When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
Install the IoT Central extension
Run the following command from your command line to install:
az extension add --name azure-iot
Check the version of the extension by running:
az --version
You should see the azure-iot extension is 0.14.1 or higher. If it isn't, run:
az extension update --name azure-iot
Using the extension
The following sections describe common commands and options that you can use when you run
az iot central
. To view the full set of commands and options, pass
--help
to az iot central
or any of its subcommands.
Sign in
Start by signing into the Azure CLI:
az login
Get the Application ID of your IoT Central app
In Application > Management, copy the Application ID. You use this value in later steps.
Monitor messages
Monitor the messages that are being sent to your IoT Central app from your devices. The output includes all headers and annotations.
az iot central diagnostics monitor-events --app-id <app-id> --properties all
View device properties
View the current read and read/write device properties for a given device.
az iot central device twin show --app-id <app-id> --device-id <device-id>
Next steps
A suggested next step is to learn Troubleshoot why data from your devices isn't showing up in Azure IoT Central.