skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. The above error was encountered due to passing incorrect subscription details in the az network private-dns zone command.

    You can use the below commands to retrieve the Subscription ID without having to pass it manually.

    $subname = az account subscription list
    $subid =  $subname | jq -r '.[].subscriptionId'
    az network private-dns zone list --subscription $subid
    

    Output:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search