0

I am trying to get the Azure Event hub connection string by using PowerShell script (ps1 file) but it's coming with primary and secondary connection strings How Do I separate these values? I am only interested primary connection string

this the document I am using powershell

Get-AzEventHubKey -ResourceGroupName MyResourceGroupName -NamespaceName MyNamespaceName -EventHubName MyEventHubName -AuthorizationRuleName MyAuthRuleName

enter image description here

2
  • 1
    Get-AzEventHubKey | Select-Object -Property PrimaryConnectionString | Format-List Commented Sep 2, 2022 at 9:57
  • 1
    (Get-AzEventHubKey -ResourceGroupName MyResourceGroupName -NamespaceName MyNamespaceName -EventHubName MyEventHubName -AuthorizationRuleName MyAuthRuleName).PrimaryConnectionString Commented Sep 2, 2022 at 10:06

1 Answer 1

1

Thanks Dai & Toni for your suggestion it helps lot to fix the issue.

Ways to filter specific Property of your command in PowerShell

Use Select-Object to select the specific property of the result.

Get-AzEventHubKey -ResourceGroupName < Resource Group Name> -NamespaceName < Event Hub Namespace Name> -EventHubName < Event Hub Name>-AuthorizationRuleName < Authorization Rule Name> | Select-Object -Property primaryConnectionString

If you are planning using CLI use -query property to select the specific property of the result

 az eventhubs eventhub authorization-rule keys list --resource-group < Resource Group Name>  --namespace-name < Event Hub Namespace Name > --eventhub-name < Event Hub Name> --name < Rule Name > --query "primaryConnectionString"

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.