IoT Hub - Create/Delete & Properties display
IoT Hub - Create
az iot hub create --name <iothubName> -resource-group <resourceGroupName> \
--sku <skuname>
For tier and pricing information refer to documentation.
IoT Hub - Delete
az iot hub delete --name <iothubName> -resource-group <resourceGroupName>
IoT Hub - Properties Display
az iot hub show --query properties.eventHubEndpoints.events.endpoint \
--name <iothubName>
az iot hub show --query properties.eventHubEndpoints.events.path \
--name <iothubName>
az iot hub policy show --name service --query primaryKey \
--hub-name <iothubName>
Display the primary connection string
az iot hub show-connection-string --name <iothubName> \
--key primary --query connectionString -o tsv
IoT Hub - Retrieving Iot Hub Connection String (Backend Apps)
az iot hub show-connection-string --policy-name service \
--name <iothubName> --output table
Generate Iot Hub SAS Token
az iot hub generate-sas-token --device-id MyTestDevice --hub-name {YourIoTHubName}
IoT Hub - Device Registration/Connect
IoT Hub - Registering a Device
az iot hub device-identity create \
--hub-name <iothubName> --device-id <devicename>
IoT Hub - Displaying a Connection String of the Device
az iot hub device-identity show-connection-string \
--hub-name <iothubName> --device-id <devicename> --output table
IoT Hub - Monitor
az iot hub monitor-events --output table --hub-name <iothubName>
IoT Hub - IP Filter Rules
IoT Hub - Retrieve current IP filters
az resource show -n <iothubName> -g <resourceGroupName> --resource-type Microsoft.Devices/IotHubs
IoT Hub - Add IP filters
az resource update -n <iothubName> -g <resourceGroupName> \
--resource-type Microsoft.Devices/IotHubs \
--add properties.ipFilterRules "{\"action\":\"Reject\",\"filterName\":\"MaliciousIP\",\"ipMask\":\"6.6.6.6/6\"}"
IoT Hub - Delete IP filters
az resource update -n <iothubName> -g <resourceGroupName> \
--resource-type Microsoft.Devices/IotHubs \
--add properties.ipFilterRules <ipFilterIndexToRemove>
Routing
Create the route for the storage endpoint
az iot hub route create \
--name $routeName \
--hub-name $iotHubName \
--source devicemessages \
--resource-group $resourceGroup \
--endpoint-name $endpointName \
--enabled \
--condition $condition
DPS
Linking DPS and IoT Hub
az iot dps linked-hub create --dps-name <dpsname> \
--resource-group <resourceGroupName> \
--connection-string <hubConnectionString> --location <location>