如何使用 Azure CLI 获取与事件中心兼容的终结点连接字符串

How to get Event Hub-compatible endpoint connection string using Azure CLI

我正在尝试使用 Azure CLI 获取物联网中心中存在的 'Event Hub-compatible endpoint' 的连接字符串。有没有获取连接字符串信息的命令?

是的,您可以使用以下命令获取 IoT Hub 的 eventhub 兼容连接字符串:

az iot hub connection-string show -n <IoT Hub name> --default-eventhub

请注意,此参考是 Azure CLI azure-iot 扩展的一部分,需要 2.0.70 或更高版本。

如下@Stefan 所详述:

需要注意的一件事是默认情况下此命令 returns iothubowner 策略的连接字符串。使用 --policy-name 参数明确指定共享访问策略,例如:

az iot hub connection-string show -n <IoT Hub name> --default-eventhub --policy-name service