sansalk
sansalk

Reputation: 4731

Separate values from PowerShell script for azure connection strings

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

Upvotes: 0

Views: 109

Answers (1)

Delliganesh Sevanesan
Delliganesh Sevanesan

Reputation: 4778

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

Upvotes: 1

Related Questions