az iot hub
Note
This command group has commands that are defined in both Azure CLI and at least one extension. Install each extension to benefit from its extended capabilities. Learn more about extensions.
Manage Azure IoT hubs.
Commands
Name | Description | Type | Status |
---|---|---|---|
az iot hub certificate |
Manage IoT Hub certificates. |
Core and Extension | GA |
az iot hub certificate create |
Create/upload an Azure IoT Hub certificate. |
Core | GA |
az iot hub certificate delete |
Deletes an Azure IoT Hub certificate. |
Core | GA |
az iot hub certificate generate-verification-code |
Generates a verification code for an Azure IoT Hub certificate. |
Core | GA |
az iot hub certificate list |
Lists all certificates contained within an Azure IoT Hub. |
Core | GA |
az iot hub certificate root-authority |
Manage the certificate root-authority for an IoT Hub instance. |
Extension | Deprecated |
az iot hub certificate root-authority set |
Set the certificate root-authority for an IoT Hub instance to a specific version. |
Extension | Deprecated |
az iot hub certificate root-authority show |
Show the current certificate root-authority for an IoT Hub instance. |
Extension | Deprecated |
az iot hub certificate show |
Shows information about a particular Azure IoT Hub certificate. |
Core | GA |
az iot hub certificate update |
Update an Azure IoT Hub certificate. |
Core | GA |
az iot hub certificate verify |
Verifies an Azure IoT Hub certificate. |
Core | GA |
az iot hub configuration |
Manage IoT automatic device management configuration at scale. |
Extension | GA |
az iot hub configuration create |
Create an IoT automatic device management configuration in a target IoT Hub. |
Extension | GA |
az iot hub configuration delete |
Delete an IoT device configuration. |
Extension | GA |
az iot hub configuration list |
List IoT automatic device management configurations in an IoT Hub. |
Extension | GA |
az iot hub configuration show |
Get the details of an IoT automatic device management configuration. |
Extension | GA |
az iot hub configuration show-metric |
Evaluate a target user or system metric defined in an IoT device configuration. |
Extension | GA |
az iot hub configuration update |
Update specified properties of an IoT automatic device management configuration. |
Extension | GA |
az iot hub connection-string |
Manage IoT Hub connection strings. |
Extension | GA |
az iot hub connection-string show |
Show the connection strings for the specified IoT Hubs using the given policy name and key. |
Extension | GA |
az iot hub consumer-group |
Manage the event hub consumer groups of an IoT hub. |
Core | GA |
az iot hub consumer-group create |
Create an event hub consumer group. |
Core | GA |
az iot hub consumer-group delete |
Delete an event hub consumer group. |
Core | GA |
az iot hub consumer-group list |
List event hub consumer groups. |
Core | GA |
az iot hub consumer-group show |
Get the details for an event hub consumer group. |
Core | GA |
az iot hub create |
Create an Azure IoT hub. |
Core | GA |
az iot hub delete |
Delete an IoT hub. |
Core | GA |
az iot hub device-identity |
Manage IoT devices. |
Extension | GA |
az iot hub device-identity children |
Manage children device relationships for IoT edge devices. |
Extension | GA |
az iot hub device-identity children add |
Add devices as children to a target edge device. |
Extension | GA |
az iot hub device-identity children list |
Outputs the collection of assigned child devices. |
Extension | GA |
az iot hub device-identity children remove |
Remove child devices from a target edge device. |
Extension | GA |
az iot hub device-identity connection-string |
Manage IoT device's connection string. |
Extension | GA |
az iot hub device-identity connection-string show |
Show a given IoT Hub device connection string. |
Extension | GA |
az iot hub device-identity create |
Create a device in an IoT Hub. |
Extension | GA |
az iot hub device-identity delete |
Delete an IoT Hub device. |
Extension | GA |
az iot hub device-identity export |
Export all device identities from an IoT Hub to an Azure Storage blob container. |
Extension | GA |
az iot hub device-identity import |
Import device identities to an IoT Hub from a storage container blob. |
Extension | GA |
az iot hub device-identity list |
List devices in an IoT Hub. |
Extension | GA |
az iot hub device-identity parent |
Manage parent device relationships for IoT devices. |
Extension | GA |
az iot hub device-identity parent set |
Set the parent device of a target device. |
Extension | GA |
az iot hub device-identity parent show |
Get the parent device of a target device. |
Extension | GA |
az iot hub device-identity renew-key |
Renew target keys of IoT Hub devices with sas authentication. |
Extension | GA |
az iot hub device-identity show |
Get the details of an IoT Hub device. |
Extension | GA |
az iot hub device-identity update |
Update an IoT Hub device. |
Extension | GA |
az iot hub device-twin |
Manage IoT device twin configuration. |
Extension | GA |
az iot hub device-twin list |
List device twins in an IoT Hub. |
Extension | GA |
az iot hub device-twin replace |
Replace device twin definition with target json. |
Extension | GA |
az iot hub device-twin show |
Get a device twin definition. |
Extension | GA |
az iot hub device-twin update |
Update device twin desired properties and tags. |
Extension | GA |
az iot hub devicestream |
Manage device streams of an IoT hub. |
Core | Preview |
az iot hub devicestream show |
Get IoT Hub's device streams endpoints. |
Core | Preview |
az iot hub digital-twin |
Manipulate and interact with the digital twin of an IoT Hub device. |
Extension | GA |
az iot hub digital-twin invoke-command |
Invoke a root or component level command of a digital twin device. |
Extension | GA |
az iot hub digital-twin show |
Show the digital twin of an IoT Hub device. |
Extension | GA |
az iot hub digital-twin update |
Update the read-write properties of a digital twin device via JSON patch specification. |
Extension | GA |
az iot hub distributed-tracing |
Manage distributed settings per-device. |
Extension | Preview |
az iot hub distributed-tracing show |
Get the distributed tracing settings for a device. |
Extension | Preview |
az iot hub distributed-tracing update |
Update the distributed tracing options for a device. |
Extension | Preview |
az iot hub generate-sas-token |
Generate a SAS token for a target IoT Hub, device or module. |
Extension | GA |
az iot hub identity |
Manage identities of an Azure IoT hub. |
Core | GA |
az iot hub identity assign |
Assign managed identities to an IoT Hub. |
Core | GA |
az iot hub identity remove |
Remove managed identities from an IoT Hub. |
Core | GA |
az iot hub identity show |
Show the identity properties of an IoT Hub. |
Core | GA |
az iot hub invoke-device-method |
Invoke a device method. |
Extension | GA |
az iot hub invoke-module-method |
Invoke a module method. |
Extension | GA |
az iot hub job |
Manage IoT Hub jobs (v2). |
Extension | GA |
az iot hub job cancel |
Cancel an IoT Hub job. |
Extension | GA |
az iot hub job create |
Create and schedule an IoT Hub job for execution. |
Extension | GA |
az iot hub job list |
List the historical jobs of an IoT Hub. |
Extension | GA |
az iot hub job show |
Show details of an existing IoT Hub job. |
Extension | GA |
az iot hub list |
List IoT hubs. |
Core | GA |
az iot hub list-skus |
List available pricing tiers. |
Core | GA |
az iot hub manual-failover |
Initiate a manual failover for the IoT Hub to the geo-paired disaster recovery region. |
Core | GA |
az iot hub message-endpoint |
Manage custom endpoints of an IoT hub. |
Extension | Preview |
az iot hub message-endpoint create |
Add an endpoint to an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint create cosmosdb-container |
Add a Cosmos DB Container endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint create eventhub |
Add an Event Hub endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint create servicebus-queue |
Add a Service Bus Queue endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint create servicebus-topic |
Add a Service Bus Topic endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint create storage-container |
Add a Storage Container endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint delete |
Delete all or a specific endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint list |
Get information on all the endpoints for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint show |
Get information on mentioned endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint update |
Update the properties of an existing endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint update cosmosdb-container |
Update the properties of an existing Cosmos DB Container endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint update eventhub |
Update the properties of an existing Event Hub endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint update servicebus-queue |
Update the properties of an existing Service Bus Queue endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint update servicebus-topic |
Update the properties of an existing Service Bus Topic endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-endpoint update storage-container |
Update the properties of an existing Storage Container endpoint for an IoT Hub. |
Extension | Preview |
az iot hub message-enrichment |
Manage message enrichments for endpoints of an IoT Hub. |
Core | GA |
az iot hub message-enrichment create |
Create a message enrichment for chosen endpoints in your IoT Hub. |
Core | GA |
az iot hub message-enrichment delete |
Delete a message enrichment in your IoT hub (by key). |
Core | GA |
az iot hub message-enrichment list |
Get information on all message enrichments for your IoT Hub. |
Core | GA |
az iot hub message-enrichment update |
Update a message enrichment in your IoT hub (by key). |
Core | GA |
az iot hub message-route |
Manage routes of an IoT hub. |
Extension | Preview |
az iot hub message-route create |
Add a route for an IoT Hub. |
Extension | Preview |
az iot hub message-route delete |
Delete all routes or a mentioned route in an IoT Hub. |
Extension | Preview |
az iot hub message-route fallback |
Manage the fallback route of an IoT hub. |
Extension | Preview |
az iot hub message-route fallback set |
Enable or disable the fallback route in an IoT Hub. |
Extension | Preview |
az iot hub message-route fallback show |
Show the fallback route of an IoT Hub. |
Extension | Preview |
az iot hub message-route list |
Get all the routes in an IoT Hub. |
Extension | Preview |
az iot hub message-route show |
Get information about the route in an IoT Hub. |
Extension | Preview |
az iot hub message-route test |
Test all routes or a mentioned route in an IoT Hub. |
Extension | Preview |
az iot hub message-route update |
Update a route for an IoT Hub. |
Extension | Preview |
az iot hub module-identity |
Manage IoT device modules. |
Extension | GA |
az iot hub module-identity connection-string |
Manage IoT device module's connection string. |
Extension | GA |
az iot hub module-identity connection-string show |
Show a target IoT device module connection string. |
Extension | GA |
az iot hub module-identity create |
Create a module on a target IoT device in an IoT Hub. |
Extension | GA |
az iot hub module-identity delete |
Delete a device in an IoT Hub. |
Extension | GA |
az iot hub module-identity list |
List modules located on an IoT device in an IoT Hub. |
Extension | GA |
az iot hub module-identity renew-key |
Renew target keys of IoT Hub device modules with sas authentication. |
Extension | GA |
az iot hub module-identity show |
Get the details of an IoT device module in an IoT Hub. |
Extension | GA |
az iot hub module-identity update |
Update an IoT Hub device module. |
Extension | GA |
az iot hub module-twin |
Manage IoT device module twin configuration. |
Extension | GA |
az iot hub module-twin replace |
Replace a module twin definition with target json. |
Extension | GA |
az iot hub module-twin show |
Show a module twin definition. |
Extension | GA |
az iot hub module-twin update |
Update module twin desired properties and tags. |
Extension | GA |
az iot hub monitor-events |
Monitor device telemetry & messages sent to an IoT Hub. |
Extension | GA |
az iot hub monitor-feedback |
Monitor feedback sent by devices to acknowledge cloud-to-device (C2D) messages. |
Extension | GA |
az iot hub policy |
Manage shared access policies of an IoT hub. |
Core | GA |
az iot hub policy create |
Create a new shared access policy in an IoT hub. |
Core | GA |
az iot hub policy delete |
Delete a shared access policy from an IoT hub. |
Core | GA |
az iot hub policy list |
List shared access policies of an IoT hub. |
Core | GA |
az iot hub policy renew-key |
Regenerate keys of a shared access policy of an IoT hub. |
Core | GA |
az iot hub policy show |
Get the details of a shared access policy of an IoT hub. |
Core | GA |
az iot hub query |
Query an IoT Hub using a powerful SQL-like language. |
Extension | GA |
az iot hub route |
Manage routes of an IoT hub. |
Core | Deprecated |
az iot hub route create |
Create a route in IoT Hub. |
Core | Deprecated |
az iot hub route delete |
Delete all or mentioned route for your IoT Hub. |
Core | Deprecated |
az iot hub route list |
Get all the routes in IoT Hub. |
Core | Deprecated |
az iot hub route show |
Get information about the route in IoT Hub. |
Core | Deprecated |
az iot hub route test |
Test all routes or mentioned route in IoT Hub. |
Core | Deprecated |
az iot hub route update |
Update a route in IoT Hub. |
Core | Deprecated |
az iot hub routing-endpoint |
Manage custom endpoints of an IoT hub. |
Core | Deprecated |
az iot hub routing-endpoint create |
Add an endpoint to your IoT Hub. |
Core | Deprecated |
az iot hub routing-endpoint delete |
Delete all or mentioned endpoint for your IoT Hub. |
Core | Deprecated |
az iot hub routing-endpoint list |
Get information on all the endpoints for your IoT Hub. |
Core | Deprecated |
az iot hub routing-endpoint show |
Get information on mentioned endpoint for your IoT Hub. |
Core | Deprecated |
az iot hub show |
Get the details of an IoT hub. |
Core | GA |
az iot hub show-connection-string |
Show the connection strings for an IoT hub. |
Core | Deprecated |
az iot hub show-quota-metrics |
Get the quota metrics for an IoT hub. |
Core | GA |
az iot hub show-stats |
Get the statistics for an IoT hub. |
Core | GA |
az iot hub state |
Manage the state of an IoT Hub. |
Extension | Experimental |
az iot hub state export |
Export the state of an IoT Hub to a file. |
Extension | Experimental |
az iot hub state import |
Import a Hub state from a file to an IoT Hub. |
Extension | Experimental |
az iot hub state migrate |
Migrate the state of one hub to another hub without saving to a file. |
Extension | Experimental |
az iot hub update |
Update metadata for an IoT hub. |
Core | GA |
az iot hub wait |
Wait until an operation on an IoT Hub instance is complete. |
Core | GA |
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}]
[--edr {false, true}]
[--fc]
[--fcs]
[--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]
[--no-wait]
[--partition-count]
[--rd]
[--role]
[--scopes]
[--sku {B1, B2, B3, F1, S1, S2, S3}]
[--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
Create an IoT Hub with data residency enforced. This will disable cross-region disaster recovery.
az iot hub create --resource-group MyResourceGroup --name MyIoTHub --edr
Required Parameters
IoT Hub name.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Optional Parameters
The number of times the IoT hub will attempt to deliver a cloud-to-device message to a device, between 1 and 100.
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.
A boolean indicating whether or not to disable all device (including Edge devices but excluding modules) scoped SAS keys for authentication.
A boolean indicating whether or not to disable IoT hub scoped SAS keys for authentication.
A boolean indicating whether or not to disable module-scoped SAS keys for authentication.
Enforce data residency for this IoT Hub by disabling cross-region disaster recovery. This property is immutable once set on the resource. Only available in select regions. Learn more at https://aka.ms/iothubdisabledr.
The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified.
The connection string for the Azure Storage account to which files are uploaded.
The number of times the IoT hub attempts to deliver a message on the feedback queue, between 1 and 100.
The lock duration for the feedback queue, between 5 and 300 seconds.
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.
The lock duration for the file upload notifications queue, between 5 and 300 seconds.
The number of times the IoT hub will attempt to deliver a file notification message, between 1 and 100.
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.
A boolean indicating whether to log information about uploaded files to the messages/servicebound/filenotifications IoT Hub endpoint.
The amount of time a SAS URI generated by IoT Hub is valid before it expires, between 1 and 24 hours.
The authentication type for the Azure Storage account to which files are uploaded.
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 of your IoT Hub. Default is the location of target resource group.
Enable system-assigned managed identity for this hub.
Enable user-assigned managed identities for this hub. Accept space-separated list of identity resource IDs.
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.
Do not wait for the long-running operation to finish.
The number of partitions of the backing Event Hub for device-to-cloud messages.
Specifies how long this IoT hub will maintain device-to-cloud events, between 1 and 7 days.
Role to assign to the hub's system-assigned managed identity.
Space separated list of scopes to assign the role (--role) for the system-assigned managed identity.
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.
Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.
Units in your IoT Hub.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
az iot hub delete
Delete an IoT hub.
az iot hub delete [--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]
Examples
Delete an IoT hub. (autogenerated)
az iot hub delete --name MyIoTHub --resource-group MyResourceGroup
Optional Parameters
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.
IoT Hub name.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
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
Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. If the authentication type is login and the resource hostname is provided, resource lookup will be skipped unless needed.You can configure the default using az configure --defaults iothub-data-auth-type={auth-type-value}
.
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.
Target Device Id.
Valid token duration in seconds.
IoT Hub name or hostname. Required if --login is not provided.
Shared access policy key type for authentication.
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.
Target Module Id.
Shared access policy with operation permissions for target IoT Hub entity.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
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 a device.
az iot hub invoke-device-method --hub-name {iothub_name} --device-id {device_id} --method-name Reboot --method-payload '{"version":"1.0"}'
Required Parameters
Target Device Id.
Target method for invocation.
Optional Parameters
Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. If the authentication type is login and the resource hostname is provided, resource lookup will be skipped unless needed.You can configure the default using az configure --defaults iothub-data-auth-type={auth-type-value}
.
IoT Hub name or hostname. Required if --login is not provided.
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.
Json payload to be passed to method. Must be file path or raw json.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Maximum number of seconds to wait for the device method result.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
az iot hub invoke-module-method
Invoke a module method.
This command supports both edge and non-edge device modules.
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 an edge device module.
az iot hub invoke-module-method -n {iothub_name} -d {device_id} -m '$edgeAgent' --method-name 'RestartModule' --method-payload '{"schemaVersion": "1.0"}'
Required Parameters
Target Device Id.
Target method for invocation.
Target Module Id.
Optional Parameters
Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. If the authentication type is login and the resource hostname is provided, resource lookup will be skipped unless needed.You can configure the default using az configure --defaults iothub-data-auth-type={auth-type-value}
.
IoT Hub name or hostname. Required if --login is not provided.
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.
Json payload to be passed to method. Must be file path or raw json.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Maximum number of seconds to wait for the module method result.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
az iot hub list
List IoT hubs.
az iot hub list [--resource-group]
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
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
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
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.
IoT Hub name.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
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
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.
IoT Hub name.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
az iot hub monitor-events
Monitor device telemetry & messages sent to an IoT Hub.
This command relies on and may install dependent Cython package (uamqp) upon first execution. https://github.com/Azure/azure-uamqp-python
Note: The event will be displayed even if the message body is non-unicode decodable, in this case the event payload portion will be displayed as {{non-decodable payload}} with the rest of the event properties that are available.
az iot hub monitor-events [--cg]
[--content-type]
[--device-id]
[--device-query]
[--enqueued-time]
[--hub-name]
[--interface]
[--login]
[--mc]
[--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
Receive the specified number of messages from hub and then shut down.
az iot hub monitor-events -n {iothub_name} --message-count {message_count}
Optional Parameters
Specify the consumer group to use when connecting to event hub endpoint.
Specify the Content-Type of the message payload to automatically format the output to that type.
Target Device Id.
Specify a custom query to filter devices.
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.
IoT Hub name or hostname. Required if --login is not provided.
Target interface identifier to filter on. For example: dtmi:com:example:TemperatureController;1.
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.
Number of telemetry messages to capture before the monitor is terminated. If not specified, monitor keeps running until meeting the timeout threshold of not receiving messages from hub.
Target Module Id.
Indicate key message properties to output. sys = system properties, app = application properties, anno = annotations.
Reinstall uamqp dependency compatible with extension version. Default: false.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Maximum seconds to maintain connection without receiving message. Use 0 for infinity.
Skip user prompts. Indicates acceptance of action. Used primarily for automation scenarios. Default: false.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
az iot hub monitor-feedback
Monitor feedback sent by devices to acknowledge cloud-to-device (C2D) messages.
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
Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. If the authentication type is login and the resource hostname is provided, resource lookup will be skipped unless needed.You can configure the default using az configure --defaults iothub-data-auth-type={auth-type-value}
.
Target Device Id.
IoT Hub name or hostname. Required if --login is not provided.
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.
Reinstall uamqp dependency compatible with extension version. Default: false.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Feedback monitor will block until a message with specific id (uuid) is received.
Skip user prompts. Indicates acceptance of action. Used primarily for automation scenarios. Default: false.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
az iot hub query
Query an IoT Hub using a powerful SQL-like language.
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
User query to be executed.
Optional Parameters
Indicates whether the operation should auto-derive a policy key or use the current Azure AD session. If the authentication type is login and the resource hostname is provided, resource lookup will be skipped unless needed.You can configure the default using az configure --defaults iothub-data-auth-type={auth-type-value}
.
IoT Hub name or hostname. Required if --login is not provided.
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.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Maximum number of elements to return. By default query has no cap.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
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
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.
IoT Hub name.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
az iot hub show-connection-string
This command has been deprecated and will be removed in a future release. Use 'IoT Extension (azure-iot) connection-string command (az iot hub connection-string show)' instead.
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
Allow to show all shared access policies.
IoT Hub name.
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.
The key to use.
Shared access policy to use.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
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
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.
IoT Hub name.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
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
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.
IoT Hub name.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
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]
[--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 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>
.
The number of times the IoT hub will attempt to deliver a cloud-to-device message to a device, between 1 and 100.
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.
A boolean indicating whether or not to disable all device (including Edge devices but excluding modules) scoped SAS keys for authentication.
A boolean indicating whether or not to disable IoT hub scoped SAS keys for authentication.
A boolean indicating whether or not to disable module-scoped SAS keys for authentication.
The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified.
The connection string for the Azure Storage account to which files are uploaded.
The number of times the IoT hub attempts to deliver a message on the feedback queue, between 1 and 100.
The lock duration for the feedback queue, between 5 and 300 seconds.
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.
The lock duration for the file upload notifications queue, between 5 and 300 seconds.
The number of times the IoT hub will attempt to deliver a file notification message, between 1 and 100.
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.
A boolean indicating whether to log information about uploaded files to the messages/servicebound/filenotifications IoT Hub endpoint.
The amount of time a SAS URI generated by IoT Hub is valid before it expires, between 1 and 24 hours.
The authentication type for the Azure Storage account to which files are uploaded.
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.
When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.
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.
IoT Hub name.
Specifies how long this IoT hub will maintain device-to-cloud events, between 1 and 7 days.
Remove a property or an element from a list. Example: --remove property.list <indexToRemove>
OR --remove propertyToRemove
.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Update an object by specifying a property path and value to set. Example: --set property1.property2=<value>
.
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.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.
Units in your IoT Hub.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
az iot hub wait
Wait until an operation on an IoT Hub instance is complete.
az iot hub wait [--created]
[--custom]
[--deleted]
[--exists]
[--ids]
[--interval]
[--name]
[--resource-group]
[--subscription]
[--timeout]
[--updated]
Examples
Wait until an existing IoT Hub instance is created
az iot hub wait -n MyIoTHub --created
Wait until an IoT Hub instance is deleted
az iot hub wait -n MyIoTHub --deleted
Wait until an existing IoT Hub instance has an Active state
az iot hub wait -n MyIoTHub --custom "properties.state=='Active'"
Optional Parameters
Wait until created with 'provisioningState' at 'Succeeded'.
Wait until the condition satisfies a custom JMESPath query. E.g. provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running'].
Wait until deleted.
Wait until the resource exists.
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.
Polling interval in seconds.
IoT Hub name.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Maximum wait in seconds.
Wait until updated with provisioningState at 'Succeeded'.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.