Reputation: 7521
Is it possible to get Azure Service Bus primaryConnectionString with AZ CLI?
Input parameters:
Upvotes: 6
Views: 2679
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
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