You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用PowerShell脚本提取Azure Event Hub的主连接字符串

如何从Get-AzEventHubKey结果中提取主连接字符串

你可以直接访问Get-AzEventHubKey返回对象的PrimaryConnectionString属性来单独获取主连接字符串,两种常用写法:

  • 分步获取,方便后续复用变量:
# 获取密钥对象
$eventHubAuthKeys = Get-AzEventHubKey -ResourceGroupName MyResourceGroupName -NamespaceName MyNamespaceName -EventHubName MyEventHubName -AuthorizationRuleName MyAuthRuleName
# 提取主连接字符串
$primaryConnStr = $eventHubAuthKeys.PrimaryConnectionString
# 输出结果
Write-Output $primaryConnStr
  • 直接一行输出:
(Get-AzEventHubKey -ResourceGroupName MyResourceGroupName -NamespaceName MyNamespaceName -EventHubName MyEventHubName -AuthorizationRuleName MyAuthRuleName).PrimaryConnectionString

Get-AzEventHubKey返回的对象包含PrimaryConnectionString、SecondaryConnectionString等多个属性,通过点语法就能精准提取你需要的主连接字符串。

内容的提问来源于stack exchange,提问作者sansalk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 08:15:43