az iot hub

Manage Azure IoT hubs.

Commands

az iot hub certificate Manage IoT Hub certificates.
az iot hub certificate create Create/upload an Azure IoT Hub certificate.
az iot hub certificate delete Deletes an Azure IoT Hub certificate.
az iot hub certificate generate-verification-code Generates a verification code for an Azure IoT Hub certificate.
az iot hub certificate list Lists all certificates contained within an Azure IoT Hub.
az iot hub certificate show Shows information about a particular Azure IoT Hub certificate.
az iot hub certificate update Update an Azure IoT Hub certificate.
az iot hub certificate verify Verifies an Azure IoT Hub certificate.
az iot hub consumer-group Manage the 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 event hub consumer groups.
az iot hub consumer-group show Get the details for 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 devicestream Manage device streams of an IoT hub.
az iot hub devicestream show Get IoT Hub's device streams endpoints.
az iot hub list List IoT hubs.
az iot hub list-skus List available pricing tiers.
az iot hub manual-failover Initiate a manual failover for the IoT Hub to the geo-paired disaster recovery region.
az iot hub message-enrichment Manage message enrichments for endpoints of an IoT Hub.
az iot hub message-enrichment create Create a message enrichment for chosen endpoints in your IoT Hub.
az iot hub message-enrichment delete Delete a message enrichment in your IoT hub (by key).
az iot hub message-enrichment list Get information on all message enrichments for your IoT Hub.
az iot hub message-enrichment update Update a message enrichment in your IoT hub (by key).
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 shared access policies of an IoT hub.
az iot hub policy renew-key Regenerate keys of a shared access policy of an IoT hub.
az iot hub policy show Get the details of a shared access policy of an IoT hub.
az iot hub route Manage routes of an IoT hub.
az iot hub route create Create a route in IoT Hub.
az iot hub route delete Delete all or mentioned route for your IoT Hub.
az iot hub route list Get all the routes in IoT Hub.
az iot hub route show Get information about the route in IoT Hub.
az iot hub route test Test all routes or mentioned route in IoT Hub.
az iot hub route update Update a route in IoT Hub.
az iot hub routing-endpoint Manage custom endpoints of an IoT hub.
az iot hub routing-endpoint create Add an endpoint to your IoT Hub.
az iot hub routing-endpoint delete Delete all or mentioned endpoint for your IoT Hub.
az iot hub routing-endpoint list Get information on all the endpoints for your IoT Hub.
az iot hub routing-endpoint show Get information on mentioned endpoint for your IoT Hub.
az iot hub show Get the details of an IoT hub.
az iot hub show-connection-string Show the connection strings for an IoT hub.
az iot hub show-quota-metrics Get the quota metrics for an IoT hub.
az iot hub show-stats Get the statistics for an IoT hub.
az iot hub update Update metadata for an IoT hub.

az iot hub create

Create an Azure IoT hub.

az iot hub create --name
--resource-group
[--c2d-max-delivery-count]
[--c2d-ttl]
[--fc]
[--fcs]
[--fcu]
[--fd]
[--feedback-lock-duration]
[--feedback-ttl]
[--fileupload-notification-max-delivery-count]
[--fileupload-notification-ttl]
[--fileupload-notifications {false, true}]
[--fileupload-sas-ttl]
[--fileupload-storage-auth-type]
[--location]
[--partition-count]
[--rd]
[--sku {B1, B2, B3, F1, S1, S2, S3}]
[--subscription]
[--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 --sku F1 --partition-count 2

Create an IoT Hub with the standard pricing tier S1 and 4 partitions, 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=<name>.

Optional Parameters

--c2d-max-delivery-count --cdd

The number of times the IoT hub will attempt to deliver a cloud-to-device message to a device, between 1 and 100.

default value: 10
--c2d-ttl --ct

The amount of time a message is available for the device to consume before it is expired by IoT Hub, between 1 and 48 hours.

default value: 1
--fc --fileupload-storage-container-name

The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified.

--fcs --fileupload-storage-connectionstring

The connection string for the Azure Storage account to which files are uploaded.

--fcu --fileupload-storage-container-uri

The container URI for the Azure Storage account to which files are uploaded.

--fd --feedback-max-delivery-count

The number of times the IoT hub attempts to deliver a message on the feedback queue, between 1 and 100.

default value: 10
--feedback-lock-duration --fld

The lock duration for the feedback queue, between 5 and 300 seconds.

default value: 5
--feedback-ttl --ft

The period of time for which the IoT hub will maintain the feedback for expiration or delivery of cloud-to-device messages, between 1 and 48 hours.

default value: 1
--fileupload-notification-max-delivery-count --fnd

The number of times the IoT hub will attempt to deliver a file notification message, between 1 and 100.

default value: 10
--fileupload-notification-ttl --fnt

The amount of time a file upload notification is available for the service to consume before it is expired by IoT Hub, between 1 and 48 hours.

default value: 1
--fileupload-notifications --fn

A boolean indicating whether to log information about uploaded files to the messages/servicebound/filenotifications IoT Hub endpoint.

accepted values: false, true
--fileupload-sas-ttl --fst

The amount of time a SAS URI generated by IoT Hub is valid before it expires, between 1 and 24 hours.

default value: 1
--fileupload-storage-auth-type --fsa

The authentication type for the Azure Storage account to which files are uploaded.Possible values are keyBased and identityBased.

--location -l

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

--partition-count

The number of partitions of the backing Event Hub for device-to-cloud messages.

default value: 4
--rd --retention-day

Specifies how long this IoT hub will maintain device-to-cloud events, between 1 and 7 days.

default value: 1
--sku

Pricing tier for Azure IoT Hub. Note that only one free IoT hub instance (F1) is allowed in each subscription. Exception will be thrown if free instances exceed one.

accepted values: B1, B2, B3, F1, S1, S2, S3
default value: S1
--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--unit

Units in your IoT Hub.

default value: 1

az iot hub delete

Delete an IoT hub.

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

Examples

Delete an IoT hub. (autogenerated)

az iot hub delete --name MyIoTHub --resource-group MyResourceGroup

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

IoT Hub name.

--resource-group -g

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

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az iot hub list

List IoT hubs.

az iot hub list [--resource-group]
[--subscription]

Examples

List all IoT hubs in a subscription.

az iot hub list

List all IoT hubs in the resource group 'MyGroup'

az iot hub list --resource-group MyGroup

Optional Parameters

--resource-group -g

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

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az iot hub list-skus

List available pricing tiers.

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

Examples

List available pricing tiers. (autogenerated)

az iot hub list-skus --name MyIoTHub

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

IoT Hub name.

--resource-group -g

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

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az iot hub manual-failover

Initiate a manual failover for the IoT Hub to the geo-paired disaster recovery region.

az iot hub manual-failover [--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]

Examples

Initiate failover “myhub” from primary to secondary region.

az iot hub manual-failover -n myhub

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

IoT Hub name.

--no-wait

Do not wait for the long-running operation to finish.

--resource-group -g

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

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az iot hub show

Get the details of an IoT hub.

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

Examples

Get the details of an IoT hub. (autogenerated)

az iot hub show --name MyIoTHub

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

IoT Hub name.

--resource-group -g

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

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az iot hub show-connection-string

Show the connection strings for an IoT hub.

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

Examples

Show the connection string of an IoT hub using default policy 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 for all IoT hubs in a resource group.

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

Show the connection strings for all IoT hubs in a subscription.

az iot hub show-connection-string

Show the connection strings for an IoT hub. (autogenerated)

az iot hub show-connection-string --key primary --policy-name MyPolicy

Optional Parameters

--all

Allow to show all shared access policies.

--hub-name --name -n

IoT Hub name.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--key

The key to use.

accepted values: primary, secondary
default value: primary
--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=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az iot hub show-quota-metrics

Get the quota metrics for an IoT hub.

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

Examples

Get the quota metrics for an IoT hub. (autogenerated)

az iot hub show-quota-metrics --ids {ids}

Get the quota metrics for an IoT hub. (autogenerated)

az iot hub show-quota-metrics --name MyIoTHub

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

IoT Hub name.

--resource-group -g

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

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az iot hub show-stats

Get the statistics for an IoT hub.

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

Examples

Get the statistics for an IoT hub. (autogenerated)

az iot hub show-stats --name MyIoTHub

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

IoT Hub name.

--resource-group -g

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

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az iot hub update

Update metadata for an IoT hub.

az iot hub update [--add]
[--c2d-max-delivery-count]
[--c2d-ttl]
[--fc]
[--fcs]
[--fcu]
[--fd]
[--feedback-lock-duration]
[--feedback-ttl]
[--fileupload-notification-max-delivery-count]
[--fileupload-notification-ttl]
[--fileupload-notifications {false, true}]
[--fileupload-sas-ttl]
[--fileupload-storage-auth-type]
[--force-string]
[--ids]
[--name]
[--rd]
[--remove]
[--resource-group]
[--set]
[--sku {B1, B2, B3, F1, S1, S2, S3}]
[--subscription]
[--unit]

Examples

Add a storage container settings

az iot hub update --name MyIotHub --fileupload-storage-connectionstring "connection-string" \ --fileupload-storage-container-name "container_name"

Add a firewall filter rule to accept traffic from the IP mask 127.0.0.0/31.

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

Update metadata for an IoT hub. (autogenerated)

az iot hub update --name MyIotHub --set properties.allocationPolicy="GeoLatency"

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

--c2d-max-delivery-count --cdd

The number of times the IoT hub will attempt to deliver a cloud-to-device message to a device, between 1 and 100.

--c2d-ttl --ct

The amount of time a message is available for the device to consume before it is expired by IoT Hub, between 1 and 48 hours.

--fc --fileupload-storage-container-name

The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified.

--fcs --fileupload-storage-connectionstring

The connection string for the Azure Storage account to which files are uploaded.

--fcu --fileupload-storage-container-uri

The container URI for the Azure Storage account to which files are uploaded.

--fd --feedback-max-delivery-count

The number of times the IoT hub attempts to deliver a message on the feedback queue, between 1 and 100.

--feedback-lock-duration --fld

The lock duration for the feedback queue, between 5 and 300 seconds.

--feedback-ttl --ft

The period of time for which the IoT hub will maintain the feedback for expiration or delivery of cloud-to-device messages, between 1 and 48 hours.

--fileupload-notification-max-delivery-count --fnd

The number of times the IoT hub will attempt to deliver a file notification message, between 1 and 100.

--fileupload-notification-ttl --fnt

The amount of time a file upload notification is available for the service to consume before it is expired by IoT Hub, between 1 and 48 hours.

--fileupload-notifications --fn

A boolean indicating whether to log information about uploaded files to the messages/servicebound/filenotifications IoT Hub endpoint.

accepted values: false, true
--fileupload-sas-ttl --fst

The amount of time a SAS URI generated by IoT Hub is valid before it expires, between 1 and 24 hours.

--fileupload-storage-auth-type --fsa

The authentication type for the Azure Storage account to which files are uploaded.Possible values are keyBased and identityBased.

--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

IoT Hub name.

--rd --retention-day

Specifies how long this IoT hub will maintain device-to-cloud events, between 1 and 7 days.

--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=<name>.

--set

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

--sku

Pricing tier for Azure IoT Hub. Note that only one free IoT hub instance (F1) is allowed in each subscription. Exception will be thrown if free instances exceed one.

accepted values: B1, B2, B3, F1, S1, S2, S3
--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--unit

Units in your IoT Hub.