Search code examples
azureazure-cli

Azure cli command cannot find existing subscriptions


I am trying to list all private dns zones in an Azure subscription with this az cli command:

az network private-dns zone list --subscription $subscriptionName

But for some subscriptions i get this error message:

ERROR: (BadRequest) The specified subscription <SUB_ID> does not exist
Code: BadRequest
Message: The specified subscription <SUB_ID> does not exist

even though I can find the subscription in the Azure portal.

It does not happen for all subscriptions i try with the command, just a handful. I can't find a correlation between the ones which work.

What can cause this error?


Solution

  • After some more digging around, it seems to be problem with the error message. It only displays the message for subscription where no DNS zone exists.

    If I call az network private-dns zone list --subscription $subscriptionName with a subscription which contains a private dns zone, no error message is displayed.