az iot hub connection-string

Note

This reference is part of the azure-iot extension for the Azure CLI (version 2.46.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]
                                  [--default-eventhub {false, true}]
                                  [--hub-name]
                                  [--key-type {primary, secondary}]
                                  [--pn]
                                  [--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

--all --show-all

Show all shared access policies for the respective IoT Hub.

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

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

Accepted values: false, true
Default value: False
--hub-name -n

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

--key-type --kt

Shared access policy key type for authentication.

Accepted values: primary, secondary
Default value: primary
--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>.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.