Azure CLI for Azure IoT
The Azure Command Line Interface (Azure CLI) is a set of commands used to create and manage Azure resources. It is available across many Azure services including Azure IoT. There are over 100 references for Azure IoT giving you the ability to work effectively with IoT services from a command line.
References for IoT
The Azure IoT CLI experience is composed of two parts: Azure CLI (commonly referred to as CLI core) and the Azure IoT CLI extension.
IoT functionality in Azure CLI core is focused on infrastructure management and configuration. IoT Hub CRUD operations, or configuring IoT Hub message routes are typical use cases for core commands.
The IoT extension introduces rich features and functionality to manage, manipulate and interact with the data, entities and objects on the infrastructure itself. For example managing fleets of devices, monitoring device-to-cloud events and invoking cloud to device methods are all enabled via the IoT extension. The Azure IoT extension for Azure CLI unlocks the use of experimental or pre-release technology contributing to its versatility in a variety of scenarios and use cases.
Core reference commands
|az iot||yes||All available Azure CLI core commands for Azure IoT.|
|az iot central||yes||Manage IoT Central assets.|
|az iot dps||yes||Manage Azure IoT Hub Device Provisioning Service.|
|az iot hub||yes||Manage Azure IoT Hub infrastructure.|
Extension reference commands
|az iot||yes||All available Azure CLI extension commands for Azure IoT.|
|az iot central||yes||Manage Azure Central (IoT Central) solutions & infrastructure.|
|az iot device||Leverage device-to-cloud and cloud-to-device messaging capabilities.|
|az dt||Manage Azure Digital Twins solutions & infrastructure.|
|az iot dps||yes||Manage entities in an Azure IoT Hub Device Provisioning Service.|
|az iot edge||Manage IoT solutions on the Edge.|
|az iot hub||yes||Manage entities in an Azure IoT Hub.|
|az iot pnp||Manage entities of an IoT Plug and Play model repository.|
Additional CLI commands for Azure services used by IoT
|az maps||core||Manage Azure Maps.|
|az timeseriesinsights||extension||Manage Azure Time Series Insights.|
Extension reference installation
Azure CLI extension references must be installed prior to use. Use the az extension add command to install an extension reference by name. Find out more about extension references in Use extensions with Azure CLI.
# install the Azure CLI extension reference for Azure IoT az extension add --name azure-iot
Popular IoT articles using the Azure CLI
- Create an IoT hub
- Manage IoT Central
- CLI driven device tutorials using Azure RTOS
- Use the IoT extension for Azure IoT Hub device management
- Deploy and monitor IoT Edge modules at scale with the Azure CLI extension for IoT
- Send Telemetry to a device and monitor it with the Azure CLI extension for IoT
- Use the Azure CLI to configure IoT Hub message routing
- Manage interfaces in a Plug and Play model repository
Azure CLI reference examples
Examples are provided with every Azure CLI reference. Although you can also complete these tasks through the Azure portal, using the Azure CLI requires a single command line. Here are a few code blocks to give you an idea of how easy it is to use the Azure CLI.
To work with Azure IoT, you'll first need a resource group. Azure resource groups are simple to create and manage with the Azure CLI.
#create a resource group az group create -location westus -name MyResourceGroup
#get a list of resource groups for a subscription az group list --subscription MySubscription --output table
It is as straightforward to create an Azure IoT Hub in the '''westus''' region in the standard pricing tier.
#create an Azure IoT hub az iot hub create --resource-group MyResourceGroup --name MyIotHub --location westus