user971741
user971741

Reputation:

az-cli not returning resources however they can be viewed through portal

I am trying to fetch a list of all Microsoft.ServiceBus/namespaces/.

az resource list --resource-type "Microsoft.ServiceBus/namespaces/" --subscription "operations"

The servicebus exists in the respective subscription and can be viewed by my same account through portal.

I am already into respective subscription and have also tried specifying it explicitly, but it only returns and empty list [].

Any idea what I am doing wrong?

Upvotes: 0

Views: 587

Answers (2)

Martin Kunc
Martin Kunc

Reputation: 471

one similar problem i had was with default resource group and location being set, my az resources did not show the resources locally, but they appeared in the Cloud portal.

I had a resource group and few storage accounts in it, the resources from resources weren't appearing locally.

Local execution:

$ az group list --output table
Name                            Location            Status
------------------------------  ------------------  ---------
production-learn-rg             germanywestcentral  Succeeded
$ az resource list --resource-group production-learn-rg
[]

From the Cloud portal:

az resource list --resource-group production-learn-rg --output table
Name                   ResourceGroup        Location            Type                               Status
---------------------  -------------------  ------------------  ---------------------------------  --------
prodmkaccount          production-learn-rg  germanywestcentral  Microsoft.Storage/storageAccounts

The reason was I had default group and location set locally, which was for some reason affecting the az resource query, even when group was specified.

Probably the default location is then applied to az resource execution when unspecified.

My defaults:

az config get
// .. shortened
  "defaults": [
    {
      "name": "group",
      "source": "C:\\Users\\marti\\.azure\\config",
      "value": "mkeventhub_rg"
    },
    {
      "name": "location",
      "source": "C:\\Users\\marti\\.azure\\config",
      "value": "westeurope"
    }

Please note default location: westeurope, while location of group where I am listing resources is in germanywestcentral.

I have unset my defaults:

az config unset defaults.location
az config unset defaults.group

And now the command returned the resources as expected even locally executed:

az resource list --resource-group production-learn-rg --output table
Name                   ResourceGroup        Location            Type                               Status
---------------------  -------------------  ------------------  ---------------------------------  --------
prodmkaccount          production-learn-rg  germanywestcentral  Microsoft.Storage/storageAccounts

and now I am getting

Upvotes: 0

Rimaz Mohommed
Rimaz Mohommed

Reputation: 1394

Your command to list the ServiceBus Namespace uses az resource instead of az servicebus

Use the following command to list your Azure ServiceBus Namespaces az servicebus namespace list [--resource-group]

Reference to Docs : https://learn.microsoft.com/en-us/cli/azure/servicebus/namespace?view=azure-cli-latest#az-servicebus-namespace-list

enter image description here

Upvotes: 0

Related Questions