使用 PowerShell 在与事件中心兼容的端点中检索构建

Retrieve build in Event Hub-compatible endpoint with PowerShell

我想获取与集线器 IoT“EventHub 兼容端点”相关的端点字符串,该字符串以 Endpoint = sb // .... 开头,可在集线器的内置端点中找到。 通过在 Azure 上创建端点,系统进行通信

Each IoT hub comes with built-in system endpoints to handle system and device messages. When you create new endpoints and routes, messages stop flowing to the built-in endpoint unless you create a separate route and direct them there.

我还没有创建任何路由端点,所以命令

Get-AzIotHubRoutingEndpoint -ResourceGroupName <r_name> -Name <iothubname> -EndpointType EventHub

应该 return 端点,没有 return 任何东西,但它是我发现的唯一给了我最低限度“找到它的希望”的命令。

提前致谢 Amf

我可以重现你的问题,它看起来像一个错误,从文档中的 example,你使用的命令是正确的方法。

如果你想在门户中获得 Event Hub-compatible endpoint,你可以使用下面的解决方法,在我的示例中,它默认使用 iothubowner 共享访问策略,你也可以使用其他例如service$endpoint就是你想要的。

$groupname = "<groupname>"
$iothubname = "<iothubname>"
$sapolicy = "iothubowner"
$a = (Get-AzResource -ResourceGroupName $groupname -ResourceType Microsoft.Devices/IotHubs -Name $iothubname).Properties.eventHubEndpoints.events.endpoint
$key = (Get-AzIotHubKey -ResourceGroupName $groupname -Name $iothubname -KeyName $sapolicy).PrimaryKey
$endpoint = "Endpoint="+ $a + ";SharedAccessKeyName="+ $sapolicy +";SharedAccessKey=" + $key + ";EntityPath=" + $iothubname