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 configuration

Manage IoT automatic device management configuration at scale.

az iot hub configuration create

Create an IoT automatic device management configuration in a target IoT Hub.

az iot hub configuration delete

Delete an IoT device configuration.

az iot hub configuration list

List IoT automatic device management configurations in an IoT Hub.

az iot hub configuration show

Get the details of an IoT automatic device management configuration.

az iot hub configuration show-metric

Evaluate a target user or system metric defined in an IoT device configuration.

az iot hub configuration update

Update specified properties of an IoT automatic device management configuration.

Use --set followed by property assignments for updating a configuration.

Note: Configuration content is immutable. Configuration properties that can be updated are 'labels', 'metrics', 'priority' and 'targetCondition'.

az iot hub connection-string

Manage IoT Hub connection strings.

az iot hub connection-string show

Show the connection strings for the specified IoT Hubs using the given policy name and key.

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 device-identity

Manage IoT devices.

az iot hub device-identity children

Manage IoT device's children device.

az iot hub device-identity children add

Add specified space-separated list of device ids as children of specified edge device.

az iot hub device-identity children list

Outputs list of assigned child devices.

az iot hub device-identity children remove

Remove devices as children from specified edge device.

az iot hub device-identity connection-string

Manage IoT device's connection string.

az iot hub device-identity connection-string show

Show a given IoT Hub device connection string.

az iot hub device-identity create

Create a device in an IoT Hub.

az iot hub device-identity delete

Delete an IoT Hub device.

az iot hub device-identity export

Export all device identities from an IoT Hub to an Azure Storage blob container. For inline blob container SAS uri input, please review the input rules of your environment.

az iot hub device-identity import

Import device identities to an IoT Hub from a blob. For inline blob container SAS uri input, please review the input rules of your environment.

az iot hub device-identity list

List devices in an IoT Hub.

az iot hub device-identity parent

Manage IoT device's parent device.

az iot hub device-identity parent set

Set the parent device of the specified device.

az iot hub device-identity parent show

Get the parent device of the specified device.

az iot hub device-identity renew-key

Renew target keys of an IoT Hub device with sas authentication.

az iot hub device-identity show

Get the details of an IoT Hub device.

az iot hub device-identity update

Update an IoT Hub device.

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 device-twin

Manage IoT device twin configuration.

az iot hub device-twin replace

Replace device twin definition with target json.

az iot hub device-twin show

Get a device twin definition.

az iot hub device-twin update

Update device twin desired properties and tags.

az iot hub digital-twin

Manipulate and interact with the digital twin of an IoT Hub device.

az iot hub digital-twin invoke-command

Invoke a root or component level command of a digital twin device.

az iot hub digital-twin show

Show the digital twin of an IoT Hub device.

az iot hub digital-twin update

Update the read-write properties of a digital twin device via JSON patch specification.

az iot hub distributed-tracing

Manage distributed settings per-device.

az iot hub distributed-tracing show

Get the distributed tracing settings for a device.

az iot hub distributed-tracing update

Update the distributed tracing options for a device.

az iot hub generate-sas-token

Generate a SAS token for a target IoT Hub, device or module.

az iot hub identity

Manage identities of an Azure IoT hub.

az iot hub identity assign

Assign managed identities to an IoT Hub.

az iot hub identity remove

Remove managed identities from an IoT Hub.

az iot hub identity show

Show the identity properties of an IoT Hub.

az iot hub invoke-device-method

Invoke a device method.

az iot hub invoke-module-method

Invoke an Edge module method.

az iot hub job

Manage IoT Hub jobs (v2).

az iot hub job cancel

Cancel an IoT Hub job.

az iot hub job create

Create and schedule an IoT Hub job for execution.

az iot hub job list

List the historical jobs of an IoT Hub.

az iot hub job show

Show details of an existing IoT Hub job.

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 module-identity

Manage IoT device modules.

az iot hub module-identity connection-string

Manage IoT device module's connection string.

az iot hub module-identity connection-string show

Show a target IoT device module connection string.

az iot hub module-identity create

Create a module on a target IoT device in an IoT Hub.

az iot hub module-identity delete

Delete a device in an IoT Hub.

az iot hub module-identity list

List modules located on an IoT device in an IoT Hub.

az iot hub module-identity renew-key

Renew target keys of an IoT Hub device module with sas authentication.

az iot hub module-identity show

Get the details of an IoT device module in an IoT Hub.

az iot hub module-identity update

Update an IoT Hub device module.

az iot hub module-twin

Manage IoT device module twin configuration.

az iot hub module-twin replace

Replace a module twin definition with target json.

az iot hub module-twin show

Show a module twin definition.

az iot hub module-twin update

Update module twin desired properties and tags.

az iot hub monitor-events

Monitor device telemetry & messages sent to an IoT Hub.

az iot hub monitor-feedback

Monitor feedback sent by devices to acknowledge cloud-to-device (C2D) messages.

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 query

Query an IoT Hub using a powerful SQL-like language.

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.

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

az iot hub create --name
                  --resource-group
                  [--c2d-max-delivery-count]
                  [--c2d-ttl]
                  [--dds {false, true}]
                  [--disable-local-auth {false, true}]
                  [--disable-module-sas {false, true}]
                  [--fc]
                  [--fcs]
                  [--fcu]
                  [--fd]
                  [--feedback-lock-duration]
                  [--feedback-ttl]
                  [--fileupload-notification-lock-duration]
                  [--fileupload-notification-max-delivery-count]
                  [--fileupload-notification-ttl]
                  [--fileupload-notifications {false, true}]
                  [--fileupload-sas-ttl]
                  [--fileupload-storage-auth-type {identityBased, keyBased}]
                  [--fileupload-storage-identity]
                  [--location]
                  [--mi-system-assigned {false, true}]
                  [--mi-user-assigned]
                  [--min-tls-version]
                  [--partition-count]
                  [--rd]
                  [--role]
                  [--scopes]
                  [--sku {B1, B2, B3, F1, S1, S2, S3}]
                  [--subscription]
                  [--tags]
                  [--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, with tags.

az iot hub create --resource-group MyResourceGroup --name MyIotHub --location westus --tags a=b c=d

Create an IoT Hub with a system-assigned managed identity, and assign a role and scope to a storage account for the created identity.

az iot hub create --resource-group MyResourceGroup --name MyIotHub --location westus --mi-system-assigned --role "Storage Blob Data Contributor" --scopes {resourceId}

Create an IoT Hub with local authentication, device SAS keys, and module SAS keys all disabled

az iot hub create --resource-group MyResourceGroup --name MyIotHub --location westus --disable-local-auth --disable-device-sas --disable-module-sas

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
--dds --disable-device-sas

A boolean indicating whether or not to disable all device (including Edge devices but excluding modules) scoped SAS keys for authentication.

accepted values: false, true
--disable-local-auth --dla

A boolean indicating whether or not to disable IoT hub scoped SAS keys for authentication.

accepted values: false, true
--disable-module-sas --dms

A boolean indicating whether or not to disable module-scoped SAS keys for authentication.

accepted values: false, true
--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-lock-duration --fnld

The lock duration for the file upload notifications queue, between 5 and 300 seconds.

default value: 5
--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.

accepted values: identityBased, keyBased
--fileupload-storage-identity --fsi

The managed identity to use for file upload authentication. Use '[system]' to refer to the system-assigned managed identity or a resource ID to refer to a user-assigned managed identity.

--location -l

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

--mi-system-assigned

Enable system-assigned managed identity for this hub.

accepted values: false, true
--mi-user-assigned

Enable user-assigned managed identities for this hub. Accept space-separated list of identity resource IDs.

--min-tls-version --mintls

Specify the minimum TLS version to support for this hub. Can be set to "1.2" to have clients that use a TLS version below 1.2 to be rejected.

--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
--role

Role to assign to the hub's system-assigned managed identity.

--scopes

Space separated list of scopes to assign the role (--role) for the system-assigned managed identity.

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

--tags

Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.

--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 generate-sas-token

Generate a SAS token for a target IoT Hub, device or module.

For device SAS tokens, the policy parameter is used to access the the device registry only. Therefore the policy should have read access to the registry. For IoT Hub tokens the policy is part of the SAS.

az iot hub generate-sas-token [--auth-type {key, login}]
                              [--connection-string]
                              [--device-id]
                              [--du]
                              [--hub-name]
                              [--key-type {primary, secondary}]
                              [--login]
                              [--module-id]
                              [--pn]
                              [--resource-group]

Examples

Generate an IoT Hub SAS token using the iothubowner policy and primary key.

az iot hub generate-sas-token -n {iothub_name}

Generate an IoT Hub SAS token using the registryRead policy and secondary key.

az iot hub generate-sas-token -n {iothub_name} --policy registryRead --key-type secondary

Generate a device SAS token using the iothubowner policy to access the {iothub_name} device registry.

az iot hub generate-sas-token -d {device_id} -n {iothub_name}

Generate a device SAS token using an IoT Hub connection string (with registry access)

az iot hub generate-sas-token -d {device_id} --login 'HostName=myhub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=12345'

Generate an Iot Hub SAS token using an IoT Hub connection string

az iot hub generate-sas-token --connection-string 'HostName=myhub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=12345'

Generate a Device SAS token using a Device connection string

az iot hub generate-sas-token --connection-string 'HostName=myhub.azure-devices.net;DeviceId=mydevice;SharedAccessKeyName=iothubowner;SharedAccessKey=12345'

Generate a Module SAS token using a Module connection string

az iot hub generate-sas-token --connection-string 'HostName=myhub.azure-devices.net;DeviceId=mydevice;ModuleId=mymodule;SharedAccessKeyName=iothubowner;SharedAccessKey=12345'

Optional Parameters

--auth-type

Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. You can configure the default using az configure --defaults iothub-data-auth-type=<auth-type-value>.

accepted values: key, login
default value: key
--connection-string --cs

Target connection string. This bypasses the IoT Hub registry and generates the SAS token directly from the supplied symmetric key without further validation. All other command parameters aside from duration will be ignored. Supported connection string types: Iot Hub, Device, Module.

--device-id -d

Target Device.

--du --duration

Valid token duration in seconds.

default value: 3600
--hub-name -n

IoT Hub name. Required if --login is not provided.

--key-type --kt

Shared access policy key type for authentication.

accepted values: primary, secondary
default value: primary
--login -l

This command supports an entity connection string with rights to perform action. Use to avoid session login via "az login". If both an entity connection string and name are provided the connection string takes priority. Required if --hub-name is not provided.

--module-id -m

Target Module.

--pn --policy-name

Shared access policy with operation permissions for target IoT Hub entity.

default value: iothubowner
--resource-group -g

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

az iot hub invoke-device-method

Invoke a device method.

az iot hub invoke-device-method --device-id
                                --method-name
                                [--auth-type {key, login}]
                                [--hub-name]
                                [--login]
                                [--method-payload]
                                [--resource-group]
                                [--timeout]

Examples

Invoke a direct method on device from the cloud.

az iot hub invoke-device-method --hub-name {iothub_name} --device-id {device_id} --method-name Reboot --method-payload '{"version":"1.0"}'

Required Parameters

--device-id -d

Target Device.

--method-name --mn

Target method for invocation.

Optional Parameters

--auth-type

Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. You can configure the default using az configure --defaults iothub-data-auth-type=<auth-type-value>.

accepted values: key, login
default value: key
--hub-name -n

IoT Hub name. Required if --login is not provided.

--login -l

This command supports an entity connection string with rights to perform action. Use to avoid session login via "az login". If both an entity connection string and name are provided the connection string takes priority. Required if --hub-name is not provided.

--method-payload --mp

Json payload to be passed to method. Must be file path or raw json.

default value: {}
--resource-group -g

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

--timeout --to

Maximum number of seconds to wait for device method result.

default value: 30

az iot hub invoke-module-method

Invoke an Edge module method.

az iot hub invoke-module-method --device-id
                                --method-name
                                --module-id
                                [--auth-type {key, login}]
                                [--hub-name]
                                [--login]
                                [--method-payload]
                                [--resource-group]
                                [--timeout]

Examples

Invoke a direct method on edge device using a module from the cloud.

az iot hub invoke-module-method -n {iothub_name} -d {device_id} -m '$edgeAgent' --method-name 'RestartModule' --method-payload '{"schemaVersion": "1.0"}'

Required Parameters

--device-id -d

Target Device.

--method-name --mn

Target method for invocation.

--module-id -m

Target Module.

Optional Parameters

--auth-type

Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. You can configure the default using az configure --defaults iothub-data-auth-type=<auth-type-value>.

accepted values: key, login
default value: key
--hub-name -n

IoT Hub name. Required if --login is not provided.

--login -l

This command supports an entity connection string with rights to perform action. Use to avoid session login via "az login". If both an entity connection string and name are provided the connection string takes priority. Required if --hub-name is not provided.

--method-payload --mp

Json payload to be passed to method. Must be file path or raw json.

default value: {}
--resource-group -g

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

--timeout --to

Maximum number of seconds to wait for device method result.

default value: 30

az iot hub list

List IoT hubs.

az iot hub list [--query-examples]
                [--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

--query-examples

Recommend JMESPath string for you. You can copy one of the query and paste it after --query parameter within double quotation marks to see the results. You can add one or more positional keywords so that we can give suggestions based on these key words.

--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 monitor-events

Monitor device telemetry & messages sent to an IoT Hub.

EXPERIMENTAL requires Python 3.5+ This command relies on and may install dependent Cython package (uamqp) upon first execution. https://github.com/Azure/azure-uamqp-python.

az iot hub monitor-events [--cg]
                          [--content-type]
                          [--device-id]
                          [--device-query]
                          [--enqueued-time]
                          [--hub-name]
                          [--interface]
                          [--login]
                          [--module-id]
                          [--properties {all, anno, app, sys}]
                          [--repair {false, true}]
                          [--resource-group]
                          [--timeout]
                          [--yes {false, true}]

Examples

Basic usage

az iot hub monitor-events -n {iothub_name}

Basic usage with an IoT Hub connection string

az iot hub monitor-events -n {iothub_name} --login 'HostName=myhub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=12345'

Basic usage when filtering on target device

az iot hub monitor-events -n {iothub_name} -d {device_id}

Basic usage when filtering targeted devices with a wildcard in the ID

az iot hub monitor-events -n {iothub_name} -d Device*

Filter devices using IoT Hub query language

az iot hub monitor-events -n {iothub_name} -q "select * from devices where tags.location.region = 'US'"

Filter device and specify an Event Hub consumer group to bind to.

az iot hub monitor-events -n {iothub_name} -d {device_id} --cg {consumer_group_name}

Receive message annotations (message headers)

az iot hub monitor-events -n {iothub_name} -d {device_id} --properties anno

Receive message annotations + system properties. Never time out.

az iot hub monitor-events -n {iothub_name} -d {device_id} --properties anno sys --timeout 0

Receive all message attributes from all device messages

az iot hub monitor-events -n {iothub_name} --props all

Receive all messages and parse message payload as JSON

az iot hub monitor-events -n {iothub_name} --content-type application/json

Optional Parameters

--cg --consumer-group -c

Specify the consumer group to use when connecting to event hub endpoint.

default value: $Default
--content-type --ct

Specify the Content-Type of the message payload to automatically format the output to that type.

--device-id -d

Target Device.

--device-query -q

Specify a custom query to filter devices.

--enqueued-time --et -e

Indicates the time that should be used as a starting point to read messages from the partitions. Units are milliseconds since unix epoch. If no time is indicated "now" is used.

--hub-name -n

IoT Hub name. Required if --login is not provided.

--interface -i

Target interface identifier to filter on. For example: dtmi:com:example:TemperatureController;1.

--login -l

This command supports an entity connection string with rights to perform action. Use to avoid session login via "az login". If both an entity connection string and name are provided the connection string takes priority. Required if --hub-name is not provided.

--module-id -m

Target Module.

--properties --props -p

Indicate key message properties to output. sys = system properties, app = application properties, anno = annotations.

accepted values: all, anno, app, sys
--repair -r

Reinstall uamqp dependency compatible with extension version. Default: false.

accepted values: false, true
--resource-group -g

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

--timeout --to -t

Maximum seconds to maintain connection without receiving message. Use 0 for infinity.

default value: 300
--yes -y

Skip user prompts. Indicates acceptance of dependency installation (if required). Used primarily for automation scenarios. Default: false.

accepted values: false, true

az iot hub monitor-feedback

Monitor feedback sent by devices to acknowledge cloud-to-device (C2D) messages.

EXPERIMENTAL requires Python 3.4+ This command relies on and may install dependent Cython package (uamqp) upon first execution. https://github.com/Azure/azure-uamqp-python.

az iot hub monitor-feedback [--auth-type {key, login}]
                            [--device-id]
                            [--hub-name]
                            [--login]
                            [--repair {false, true}]
                            [--resource-group]
                            [--wait-on-msg]
                            [--yes {false, true}]

Examples

Basic usage

az iot hub monitor-feedback -n {iothub_name}

Basic usage with an IoT Hub connection string

az iot hub monitor-feedback -n {iothub_name} --login 'HostName=myhub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=12345'

Basic usage when filtering on target device

az iot hub monitor-feedback -n {iothub_name} -d {device_id}

Exit feedback monitor upon receiving a message with specific id (uuid)

az iot hub monitor-feedback -n {iothub_name} -d {device_id} -w {message_id}

Optional Parameters

--auth-type

Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. You can configure the default using az configure --defaults iothub-data-auth-type=<auth-type-value>.

accepted values: key, login
default value: key
--device-id -d

Target Device.

--hub-name -n

IoT Hub name. Required if --login is not provided.

--login -l

This command supports an entity connection string with rights to perform action. Use to avoid session login via "az login". If both an entity connection string and name are provided the connection string takes priority. Required if --hub-name is not provided.

--repair -r

Reinstall uamqp dependency compatible with extension version. Default: false.

accepted values: false, true
--resource-group -g

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

--wait-on-msg -w

Feedback monitor will block until a message with specific id (uuid) is received.

--yes -y

Skip user prompts. Indicates acceptance of dependency installation (if required). Used primarily for automation scenarios. Default: false.

accepted values: false, true

az iot hub query

Query an IoT Hub using a powerful SQL-like language.

Query an IoT Hub using a powerful SQL-like language to retrieve information regarding device and module twins, jobs and message routing. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language for more information.

az iot hub query --query-command
                 [--auth-type {key, login}]
                 [--hub-name]
                 [--login]
                 [--resource-group]
                 [--top]

Examples

Query all device twin data in an Azure IoT Hub.

az iot hub query -n {iothub_name} -q "select * from devices"

Query all module twin data on target device.

az iot hub query -n {iothub_name} -q "select * from devices.modules where devices.deviceId = '{device_id}'"

Required Parameters

--query-command -q

User query to be executed.

Optional Parameters

--auth-type

Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. You can configure the default using az configure --defaults iothub-data-auth-type=<auth-type-value>.

accepted values: key, login
default value: key
--hub-name -n

IoT Hub name. Required if --login is not provided.

--login -l

This command supports an entity connection string with rights to perform action. Use to avoid session login via "az login". If both an entity connection string and name are provided the connection string takes priority. Required if --hub-name is not provided.

--resource-group -g

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

--top

Maximum number of elements to return. By default query has no cap.

az iot hub show

Get the details of an IoT hub.

az iot hub show [--ids]
                [--name]
                [--query-examples]
                [--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.

--query-examples

Recommend JMESPath string for you. You can copy one of the query and paste it after --query parameter within double quotation marks to see the results. You can add one or more positional keywords so that we can give suggestions based on these key words.

--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]
                  [--dds {false, true}]
                  [--disable-local-auth {false, true}]
                  [--disable-module-sas {false, true}]
                  [--fc]
                  [--fcs]
                  [--fcu]
                  [--fd]
                  [--feedback-lock-duration]
                  [--feedback-ttl]
                  [--fileupload-notification-lock-duration]
                  [--fileupload-notification-max-delivery-count]
                  [--fileupload-notification-ttl]
                  [--fileupload-notifications {false, true}]
                  [--fileupload-sas-ttl]
                  [--fileupload-storage-auth-type {identityBased, keyBased}]
                  [--fileupload-storage-identity]
                  [--force-string]
                  [--ids]
                  [--name]
                  [--rd]
                  [--remove]
                  [--resource-group]
                  [--set]
                  [--sku {B1, B2, B3, F1, S1, S2, S3}]
                  [--subscription]
                  [--tags]
                  [--unit]

Examples

Add storage container settings to file upload

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"

Update units of an IoT Hub to 2 and add tags

az iot hub update -n MyIotHub --unit 2 --tags a=b c=d

Update pricing tier for an IoT Hub as S2

az iot hub update -n MyIotHub --sku S2

Update the retention days of IoT Hub device-to-cloud events as 3 days

az iot hub update -n MyIotHub --retention-day 3

Update the IoT Hub cloud-to-device messaging settings

az iot hub update --name MyIotHub --c2d-max-delivery-count 30 --c2d-ttl 5

Update the IoT Hub feedback queue settings

az iot hub update --name MyIoTHub --feedback-max-delivery-count 20 --feedback-lock-duration 100 --feedback-ttl 4

Update the IoT Hub file upload settings, and assign a managed identity to user for file upload

az iot hub update -n MyIoTHub --fileupload-sas-ttl 5 --fileupload-storage-auth-type identityBased --fileupload-storage-identity [system]

Update the IoT Hub file upload notification settings and queue lock duration

az iot hub update -n MyIoTHub --fileupload-notification-max-delivery-count 50 --fileupload-notification-ttl 48 --fileupload-notifications --fileupload-notification-lock-duration 10

Update the IoT Hub local authentication, device SAS, and module SAS settings

az iot hub update -n MyIoTHub --disable-local-auth --disable-device-sas false --disable-module-sas true

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.

--dds --disable-device-sas

A boolean indicating whether or not to disable all device (including Edge devices but excluding modules) scoped SAS keys for authentication.

accepted values: false, true
--disable-local-auth --dla

A boolean indicating whether or not to disable IoT hub scoped SAS keys for authentication.

accepted values: false, true
--disable-module-sas --dms

A boolean indicating whether or not to disable module-scoped SAS keys for authentication.

accepted values: false, true
--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-lock-duration --fnld

The lock duration for the file upload notifications queue, between 5 and 300 seconds.

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

accepted values: identityBased, keyBased
--fileupload-storage-identity --fsi

The managed identity to use for file upload authentication. Use '[system]' to refer to the system-assigned managed identity or a resource ID to refer to a user-assigned managed identity.

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

--tags

Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.

--unit

Units in your IoT Hub.