qwazer
qwazer

Reputation: 7521

Retrieve Service Bus primaryConnectionString with az cli

Is it possible to get Azure Service Bus primaryConnectionString with AZ CLI?

Input parameters:

  1. Resource Group
  2. Service Bus Name

Upvotes: 6

Views: 2679

Answers (2)

Keisha W
Keisha W

Reputation: 756

Years later it's now supported. In case anyone else stumbles upon this question like me, it can be done this way:

az servicebus namespace authorization-rule keys list --resource-group myresourcegroup --namespace-name mynamespace --name RootManageSharedAccessKey --query primaryConnectionString -o tsv

Upvotes: 20

Shui shengbao
Shui shengbao

Reputation: 19195

For now, Azure CLI 2.0 does not support service bus. You could use az -h to check. Power Shell and Azure CLI 1.0(asm mode) support service bus now.

You could use Power Shell to get primary ConnectionString.

$CurrentRule = Get-AzureRmServiceBusNamespaceAuthorizationRule -ResourceGroup $ResGrpName -NamespaceName $Namespace -AuthorizationRuleName $AuthRule
$AuthRule=$CurrentRule.Name
(Get-AzureRmServiceBusNamespaceKey -ResourceGroup shuibus -NamespaceName shuitest -AuthorizationRuleName $AuthRule).PrimaryConnectionString

More information please refer to this link.

Update:

On a Linux VM, you could use this Rest API to automation generate connectionstring.

POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys?api-version=2015-08-01

Upvotes: 2

Related Questions