【问题标题】:Retrieve build in Event Hub-compatible endpoint with PowerShell使用 PowerShell 在与事件中心兼容的终结点中检索构建
【发布时间】:2021-01-29 14:13:22
【问题描述】:

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

每个物联网中心都带有内置的系统端点来处理系统和 设备消息。当您创建新的端点和路由时,消息 除非您创建单独的端点,否则停止流向内置端点 路由并引导他们到那里。

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

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

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

提前谢谢你 AMF

【问题讨论】:

    标签: azure azure-powershell azure-iot-hub


    【解决方案1】:

    我可以重现您的问题,它看起来像一个错误,来自文档中的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
    

    【讨论】:

    • 几乎完美 :-) IoT 中心将与事件中心兼容的名称截断为 25 个字符。所以我最终将最后一行替换为: $endpoint = "Endpoint="+ $a + ";SharedAccessKeyName="+ $sapolicy +";SharedAccessKey=" + $key + ";EntityPath=" + $iothubname.substring (0,25)
    猜你喜欢
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2022-10-13
    • 2017-11-30
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    • 2012-10-22
    相关资源
    最近更新 更多