Is it possible to get Azure Service Bus primaryConnectionString with AZ CLI?
Input parameters:
- Resource Group
- Service Bus Name
Is it possible to get Azure Service Bus primaryConnectionString with AZ CLI?
Input parameters:
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
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
Invoke-RestMethod
. Now, I use curl
for test, I will give you the result. –
Monto authorizationRuleName
name is RootManageSharedAccessKey
–
Monto © 2022 - 2024 — McMap. All rights reserved.