I'm trying to use the Get-AzureRmServiceBusNamespace
module to retrieve a specific Service Bus namespace using the -Name
parameter.
The documentation for this cmdlet implies that this parameter can be used to retrieve a specific namespace or group of namespaces by the resource group. When I try to do this, the response includes all namespaces. I have also tried using the alias for this parameter (NamespaceName
). What is interesting is that the -ResourceGroupName
parameter does narrow down the results. I can retrieve the specific ServiceBus by piping the output to the Where-Object
cmdlet with a filter on the Name
property, but that feels kludgey.
Any idea what I am doing wrong?
This command essentially calls different REST APIs when you pass different parameters.
If you just run it without any parameter i.e. Get-AzureRmServiceBusNamespace
, it will list all the namespaces in the subscription, i.e. call the API Namespaces - List
.
If you pass the resource group name, it will list all the namespaces in the resource group i.e. call Namespaces - List By Resource Group
.
So in your case, if you want to get a specific namespace, you need to pass the resource group and namespace name, i.e. call Namespaces - Get
.
Get-AzureRmServiceBusNamespace -ResourceGroup <resourceGroupName> -NamespaceName <namespaceName>
Besides, the old AzureRM
module has been deprecated, I recommend you to use the new Az
command Get-AzServiceBusNamespace
instead.