az iot hub connection-string

Note

This reference is part of the azure-iot extension for the Azure CLI (version 2.70.0 or higher). The extension will automatically install the first time you run an az iot hub connection-string command. Learn more about extensions.

Manage IoT Hub connection strings.

Commands

Name Description Type Status
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 connection-string show

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

az iot hub connection-string show [--all --show-all]
                                  [--default-eventhub --eh {false, true}]
                                  [--hostname-type --ht {auto, classic, device, service}]
                                  [--hub-name]
                                  [--key-type --kt {primary, secondary}]
                                  [--pn --policy-name]
                                  [--resource-group]

Examples

Show the connection strings for all active state IoT Hubs in a subscription using the default policy and primary key.

az iot hub connection-string show

Show the connection strings for all active state IoT Hubs in a resource group using the default policy and primary key.

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

Show all connection strings of the given IoT Hub using primary key.

az iot hub connection-string show -n MyIotHub --all

Show the connection string of the given IoT Hub using the default policy and primary key.

az iot hub connection-string show -n MyIotHub

Show the connection string of the given IoT Hub using policy 'service' and secondary key.

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

Show the eventhub compatible connection string of the given IoT Hub's default eventhub.

az iot hub connection-string show -n MyIotHub --default-eventhub

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--all --show-all

Show all shared access policies for the respective IoT Hub.

Property Value
Default value: False
--default-eventhub --eh

Flag indicating the connection string returned is for the default EventHub endpoint. Default: false.

Property Value
Default value: False
Accepted values: false, true
--hostname-type --ht
Preview

Type of hostname to use in the connection string. 'auto' uses the TLS 1.3 device hostname on GWv2 hubs, classic otherwise. 'classic' always uses the default hostname. 'device' uses the TLS 1.3 device hostname (errors if not GWv2). 'service' uses the TLS 1.3 service hostname (errors if not GWv2).

Property Value
Default value: auto
Accepted values: auto, classic, device, service
--hub-name -n

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

Property Value
Parameter group: IoT Hub Identifier Arguments
--key-type --kt

Shared access policy key type for authentication.

Property Value
Default value: primary
Accepted values: primary, secondary
--pn --policy-name

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

Property Value
Default value: iothubowner
--resource-group -g

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

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

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

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False