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
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.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.Output: