IoT hubs - az iot hub

Manage Azure IoT Hubs.

These commands are in preview.

Commands

az iot hub consumer-group Manage event hub consumer groups of an IoT Hub.
az iot hub consumer-group create Create an event hub consumer group.
az iot hub consumer-group delete Delete an event hub consumer group.
az iot hub consumer-group list List all event hub consumer groups.
az iot hub consumer-group show Get an event hub consumer group.
az iot hub create Create an Azure IoT Hub.
az iot hub delete Delete an IoT Hub.
az iot hub job Manage jobs in an IoT Hub.
az iot hub job cancel Cancel a job in an IoT Hub.
az iot hub job list List all jobs in an IoT Hub.
az iot hub job show Show a job in an IoT Hub.
az iot hub list List IoT Hubs.
az iot hub list-skus List all valid pricing tiers.
az iot hub policy Manage shared access policies of an IoT Hub.
az iot hub policy create Create a new shared access policy in an IoT Hub.
az iot hub policy delete Delete a shared access policy from an IoT Hub.
az iot hub policy list List all shared access policies of an IoT Hub.
az iot hub policy show Get a shared access policy of an IoT Hub.
az iot hub show Show non-security metadata of an IoT Hub.
az iot hub show-connection-string Show the connection string of an IoT Hub.
az iot hub show-quota-metrics Show quota metrics for an IoT Hub.
az iot hub show-stats Show statistics of an IoT Hub.
az iot hub update Update non-security metadata of an IoT Hub.

az iot hub create

For an introduction to Azure IoT Hub, see https://docs.microsoft.com/azure/iot-hub/.

az iot hub create --name
--resource-group
[--location]
[--sku {F1, S1, S2, S3}]
[--unit]

Examples

Create an IoT Hub with the free pricing tier F1, in the region of the resource group.

az iot hub create --resource-group MyResourceGroup --name MyIotHub

Create an IoT Hub with the standard pricing tier S1, in the region of the resource group.

az iot hub create --resource-group MyResourceGroup --name MyIotHub --sku S1

Create an IoT Hub with the free pricing tier F1, in the `westus` region.

az iot hub create --resource-group MyResourceGroup --name MyIotHub --location westus

Required Parameters

--name -n

IoT Hub name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

Optional Parameters

--location -l

Location of your IoT Hub. Default is the location of target resource group.

--sku

Pricing tier for Azure IoT Hub. Default value is F1, which is free. Note that only one free IoT Hub instance is allowed in each subscription. Exception will be thrown if free instances exceed one.

accepted values: F1, S1, S2, S3
default value: F1
--unit

Units in your IoT Hub.

default value: 1

az iot hub delete

Delete an IoT Hub.

az iot hub delete --name
[--resource-group]

Required Parameters

--name -n

IoT Hub name.

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

az iot hub list

If the resource group is provided, IoT Hubs in the target resource group are listed. Otherwise, IoT Hubs in your subscription are listed.

az iot hub list [--resource-group]

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

az iot hub list-skus

List all valid pricing tiers.

az iot hub list-skus --name
[--resource-group]

Required Parameters

--name -n

IoT Hub name.

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

az iot hub show

Show non-security metadata of an IoT Hub.

az iot hub show --name
[--resource-group]

Required Parameters

--name -n

IoT Hub name.

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

az iot hub show-connection-string

If resource group and IoT Hub name are not provided, connection strings for all IoT Hubs in your subscription are returned. If only the resource group is provided, connection strings for all IoT Hubs in the resource group are returned. If both resource group and IoT Hub name are provided, the connection string of the IoT Hub is returned.

az iot hub show-connection-string [--key {primary, secondary}]
[--name]
[--policy-name]
[--resource-group]

Examples

Show the connection string of an IoT Hub using default policy (`iothubowner`) and primary key.

az iot hub show-connection-string --name MyIotHub

Show the connection string of an IoT Hub using policy `service` and secondary key.

az iot hub show-connection-string --name MyIotHub --policy-name service --key secondary

Show the connection strings of all IoT Hubs in a resource group.

az iot hub show-connection-string --resource-group MyResourceGroup

Show the connection strings of all IoT Hubs in a subscription.

az iot hub show-connection-string

Optional Parameters

--key

The key to use.

accepted values: primary, secondary
default value: primary
--name -n

IoT Hub name.

--policy-name

Shared access policy to use.

default value: iothubowner
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

az iot hub show-quota-metrics

Show quota metrics for an IoT Hub.

az iot hub show-quota-metrics --name
[--resource-group]

Required Parameters

--name -n

IoT Hub name.

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

az iot hub show-stats

Show statistics of an IoT Hub.

az iot hub show-stats --name
[--resource-group]

Required Parameters

--name -n

IoT Hub name.

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

az iot hub update

Update non-security metadata of an IoT Hub.

az iot hub update --name
[--add]
[--remove]
[--resource-group]
[--set]

Examples

Add an IP filter rule.

az iot hub update --name MyIotHub --add properties.ipFilterRules filter_name=test-rule action=Accept ip_mask=127.0.0.0/31 az iot hub update --name MyIotHub --add properties.ipFilterRules filter_name=test-rule action=Reject ip_mask=127.0.0.0/31

Required Parameters

--name -n

IoT Hub name.

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty .

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.